結果

問題 No.3221 Count Turns
ユーザー Brandon Li
提出日時 2025-08-01 22:51:23
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 119 ms / 2,000 ms
コード長 1,175 bytes
コンパイル時間 1,838 ms
コンパイル使用メモリ 202,084 KB
実行使用メモリ 18,048 KB
最終ジャッジ日時 2025-08-01 22:51:33
合計ジャッジ時間 5,259 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...) 0
#define dbgn(...) 0
#endif

int32_t main() {
    cin.tie(0)->sync_with_stdio(0);
    ll n, h, t;
    cin >> n >> h >> t;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<ll> c(n, 0);
    vector<ll> lst(n, 0);
    set<pair<ll, int>> pq;
    for (int i = 0; i < n; i++) {
        pq.insert({(h + a[i] - 1) / a[i], i});
    }
    while (t > 0 && !pq.empty()) {
        ll nxt = pq.begin()->first;
        set<pair<ll, int>> curr;

        while (!pq.empty() && pq.begin()->first == nxt) {
            int idx = pq.begin()->second;
            pq.erase(pq.begin());
            curr.insert({-(nxt - lst[idx]) * a[idx], idx});
        }
        for (auto x : curr) {
            if (t == 0) {
                break;
            }
            int idx = x.second;
            c[idx]++;
            t--;
            lst[idx] = nxt;
            pq.insert({nxt + (h + a[idx] - 1) / a[idx], idx});
        }
    }
    for (int i = 0; i < n; i++) {
        cout << c[i] << ' ';
    }
    cout << '\n';
    return 0;
}
0