結果

問題 No.2453 Seat Allocation
ユーザー PAKACHUPAKACHU
提出日時 2023-09-01 22:40:14
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 261 ms / 2,000 ms
コード長 948 bytes
コンパイル時間 3,595 ms
コンパイル使用メモリ 133,572 KB
実行使用メモリ 9,756 KB
最終ジャッジ日時 2023-09-07 15:36:38
合計ジャッジ時間 8,116 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 237 ms
9,756 KB
testcase_06 AC 171 ms
4,376 KB
testcase_07 AC 40 ms
8,992 KB
testcase_08 AC 21 ms
4,376 KB
testcase_09 AC 253 ms
9,504 KB
testcase_10 AC 255 ms
8,824 KB
testcase_11 AC 261 ms
8,908 KB
testcase_12 AC 179 ms
4,380 KB
testcase_13 AC 182 ms
4,376 KB
testcase_14 AC 177 ms
4,380 KB
testcase_15 AC 187 ms
4,376 KB
testcase_16 AC 168 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 195 ms
5,912 KB
testcase_19 AC 215 ms
9,492 KB
testcase_20 AC 86 ms
5,632 KB
testcase_21 AC 133 ms
4,376 KB
testcase_22 AC 193 ms
4,620 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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