結果

問題 No.2453 Seat Allocation
ユーザー PAKACHU
提出日時 2023-09-01 22:40:14
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 242 ms / 2,000 ms
コード長 948 bytes
コンパイル時間 4,244 ms
コンパイル使用メモリ 170,976 KB
実行使用メモリ 9,964 KB
最終ジャッジ日時 2025-06-20 01:45:54
合計ジャッジ時間 8,282 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
int dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const long long mod = 998244353;
const ll inf = 1LL << 60;
const int INF = 5e8;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < m; i++)
        cin >> b[i];

    vector<int> c(n);
    priority_queue<pair<ld, int>, vector<pair<ld, int>>> q;
    for (int i = 0; i < n; i++) {
        q.emplace((ld)a[i] / b[0], -i);
        c[i]++;
    }

    int sz = 0;
    while (q.size()) {
        auto [_, i] = q.top();
        q.pop();
        if (sz == m)
            break;
        i *= -1;
        cout << i + 1 << endl;
        sz++;
        if (c[i] < m) {
            q.emplace((ld)a[i] / b[c[i]], -i);
            c[i]++;
        }
    }
}
0