結果

問題 No.3221 Count Turns
ユーザー jiangxinyang
提出日時 2025-08-01 21:59:17
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 947 bytes
コンパイル時間 1,531 ms
コンパイル使用メモリ 198,852 KB
実行使用メモリ 11,384 KB
最終ジャッジ日時 2025-08-01 21:59:22
合計ジャッジ時間 4,087 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const int N = 200005;
const int INF = 0x3f3f3f3f;
struct Node {
    ll v, k;
    int pos;
};
bool operator<(Node x, Node y) {
    if (x.v != y.v) return x.v > y.v;
    if (x.k != y.k) return x.k < y.k;
    return x.pos > y.pos;
}
ll a[N];
ll b[N], c[N];
ll res[N];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, h, _;
    cin >> n >> h >> _;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) {
        b[i] = (h + a[i] - 1) / a[i];
        c[i] = b[i] * a[i];
    }
    priority_queue<Node> pq;
    for (int i = 1; i <= n; i++) pq.push({b[i], c[i], i});
    while (_--) {
        auto [v, k, pos] = pq.top();
        pq.pop();
        res[pos]++;
        pq.push({v + b[pos], c[pos], pos});
    }
    for (int i = 1; i <= n; i++) cout << res[i] << " ";
    cout << "\n";
    return 0;
}
0