提出 #72428947


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;

#define all(v) (v).begin(),(v).end()
#define rep(i, n) for(int i=0;i<(n);i++)
using ll = long long;

int main() {
    ll n, k, x; cin >> n >> k >> x;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a)); reverse(all(a));
    cout << a[0] * k << endl;
    priority_queue<tuple<ll, ll, ll, ll>> pq;
    // {sum, i, pstate, nowstate};
    pq.push({a[0] * (k - 1) + a[1], 0, n - 1, 1});
    rep(_, x - 1) {
        auto [sum, i, pstate, nowstate] = pq.top();
        cout << sum << endl;
        pq.pop();
        if(nowstate < pstate) pq.push({sum - a[nowstate] + a[nowstate + 1], i, pstate, nowstate + 1});
        if(i + 1 < k) pq.push({sum - a[0] + a[1], i + 1, nowstate, 1});
    }
    return 0;
}

提出情報

提出日時
問題 E - Cookies
ユーザ shinchan
言語 C++23 (GCC 15.2.0)
得点 450
コード長 783 Byte
結果 AC
実行時間 55 ms
メモリ 5492 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 450 / 450
結果
AC × 3
AC × 34
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, hand_02.txt, hand_03.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, sample_01.txt, sample_02.txt, sample_03.txt
ケース名 結果 実行時間 メモリ
hand_01.txt AC 2 ms 3452 KiB
hand_02.txt AC 1 ms 3568 KiB
hand_03.txt AC 1 ms 3508 KiB
random_01.txt AC 46 ms 3552 KiB
random_02.txt AC 46 ms 3564 KiB
random_03.txt AC 43 ms 3552 KiB
random_04.txt AC 42 ms 3576 KiB
random_05.txt AC 41 ms 3540 KiB
random_06.txt AC 42 ms 3628 KiB
random_07.txt AC 1 ms 3424 KiB
random_08.txt AC 1 ms 3588 KiB
random_09.txt AC 46 ms 3588 KiB
random_10.txt AC 44 ms 3588 KiB
random_11.txt AC 45 ms 3600 KiB
random_12.txt AC 44 ms 3536 KiB
random_13.txt AC 54 ms 4492 KiB
random_14.txt AC 54 ms 4488 KiB
random_15.txt AC 54 ms 5492 KiB
random_16.txt AC 53 ms 4504 KiB
random_17.txt AC 55 ms 3804 KiB
random_18.txt AC 2 ms 3568 KiB
random_19.txt AC 51 ms 3756 KiB
random_20.txt AC 1 ms 3516 KiB
random_21.txt AC 54 ms 4464 KiB
random_22.txt AC 54 ms 4472 KiB
random_23.txt AC 50 ms 3732 KiB
random_24.txt AC 51 ms 3944 KiB
random_25.txt AC 43 ms 3704 KiB
random_26.txt AC 54 ms 3756 KiB
random_27.txt AC 51 ms 3840 KiB
random_28.txt AC 39 ms 3824 KiB
sample_01.txt AC 1 ms 3448 KiB
sample_02.txt AC 1 ms 3416 KiB
sample_03.txt AC 1 ms 3608 KiB