提出 #72482456


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5 + 5;

int n, m, k;
ll a[N];
priority_queue<array<ll, 4>> _S; // val, c, cur, pre
void solve() {
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + 1 + n, greater());
    _S.push({a[1] * m, 2, 0, m});
    while(k > 0) {
        auto [val, c, cur, pre] = _S.top(); _S.pop();
        cout << val << endl;
        k--;

        if(m > 0) {
            if(pre > 0) {
                _S.push({val - a[c - 1] + a[c], c, cur + 1, pre - 1});
            }
            if(cur > 0 && c + 1 <= n) {
                _S.push({val - a[c] + a[c + 1], c + 1, 1, cur - 1});
            }
        }
    }
    assert(k == 0);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    // freopen("A.in", "r", stdin);
    // freopen("A.out", "w", stdout);
    int T = 1;
    // cin >> T;
    while(T--) solve();
}

提出情報

提出日時
問題 E - Cookies
ユーザ wkl
言語 C++23 (GCC 15.2.0)
得点 450
コード長 987 Byte
結果 AC
実行時間 47 ms
メモリ 4640 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 1 ms 3728 KiB
hand_02.txt AC 1 ms 3488 KiB
hand_03.txt AC 1 ms 3488 KiB
random_01.txt AC 40 ms 3708 KiB
random_02.txt AC 40 ms 3748 KiB
random_03.txt AC 37 ms 3700 KiB
random_04.txt AC 36 ms 3644 KiB
random_05.txt AC 36 ms 3620 KiB
random_06.txt AC 36 ms 3484 KiB
random_07.txt AC 1 ms 3652 KiB
random_08.txt AC 1 ms 3672 KiB
random_09.txt AC 37 ms 3564 KiB
random_10.txt AC 36 ms 3620 KiB
random_11.txt AC 36 ms 3548 KiB
random_12.txt AC 36 ms 3620 KiB
random_13.txt AC 47 ms 4624 KiB
random_14.txt AC 47 ms 4640 KiB
random_15.txt AC 44 ms 3992 KiB
random_16.txt AC 45 ms 4568 KiB
random_17.txt AC 47 ms 3888 KiB
random_18.txt AC 1 ms 3512 KiB
random_19.txt AC 43 ms 3996 KiB
random_20.txt AC 1 ms 3488 KiB
random_21.txt AC 47 ms 4536 KiB
random_22.txt AC 47 ms 4496 KiB
random_23.txt AC 45 ms 4628 KiB
random_24.txt AC 45 ms 4588 KiB
random_25.txt AC 36 ms 3912 KiB
random_26.txt AC 45 ms 3804 KiB
random_27.txt AC 42 ms 3820 KiB
random_28.txt AC 32 ms 3856 KiB
sample_01.txt AC 1 ms 3572 KiB
sample_02.txt AC 1 ms 3644 KiB
sample_03.txt AC 1 ms 3664 KiB