提出 #72369611


ソースコード 拡げる

#include <iostream>
#include <queue>
#include <algorithm>
#define fastio cin.tie(0)->sync_with_stdio(0)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end())
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
int main() {
    fastio; int N, K, X; cin >> N >> K >> X;
    vector<ll> v(N);
    for (auto& i : v) cin >> i;
    sort(rall(v));
    priority_queue<tuple<ll,int,vector<int>>> pq;
    vector<int> cnt(N); cnt[0] = K; ll sum = v[0]*K;
    pq.push({ sum, 0, cnt });
    vector<ll> ans;
    while (!pq.empty()) {
        auto [sum, idx, cnt] = pq.top(); pq.pop();
        ans.push_back(sum);
        if (sz(ans) >= X) break;
        for (int i = idx; i < N-1; i++) {
            if (cnt[i] > 0) {
                cnt[i]--; cnt[i+1]++;
                pq.push({ sum-v[i]+v[i+1], i, cnt });
                cnt[i]++; cnt[i+1]--;
            }
        }
    }
    for (auto i : ans) cout << i << "\n";
    return 0;
}

提出情報

提出日時
問題 E - Cookies
ユーザ Lov34ever
言語 C++23 (GCC 15.2.0)
得点 450
コード長 1066 Byte
結果 AC
実行時間 32 ms
メモリ 9524 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 3584 KiB
hand_02.txt AC 1 ms 3592 KiB
hand_03.txt AC 1 ms 3616 KiB
random_01.txt AC 15 ms 4664 KiB
random_02.txt AC 15 ms 4452 KiB
random_03.txt AC 10 ms 4560 KiB
random_04.txt AC 10 ms 4584 KiB
random_05.txt AC 9 ms 4652 KiB
random_06.txt AC 10 ms 4648 KiB
random_07.txt AC 1 ms 3552 KiB
random_08.txt AC 1 ms 3596 KiB
random_09.txt AC 10 ms 4592 KiB
random_10.txt AC 9 ms 4456 KiB
random_11.txt AC 9 ms 4648 KiB
random_12.txt AC 9 ms 4648 KiB
random_13.txt AC 32 ms 9420 KiB
random_14.txt AC 29 ms 6844 KiB
random_15.txt AC 22 ms 6896 KiB
random_16.txt AC 23 ms 8060 KiB
random_17.txt AC 31 ms 6644 KiB
random_18.txt AC 1 ms 3568 KiB
random_19.txt AC 21 ms 6480 KiB
random_20.txt AC 1 ms 3616 KiB
random_21.txt AC 32 ms 9524 KiB
random_22.txt AC 29 ms 7012 KiB
random_23.txt AC 24 ms 8744 KiB
random_24.txt AC 24 ms 7748 KiB
random_25.txt AC 22 ms 4788 KiB
random_26.txt AC 29 ms 4820 KiB
random_27.txt AC 18 ms 4860 KiB
random_28.txt AC 13 ms 4672 KiB
sample_01.txt AC 1 ms 3440 KiB
sample_02.txt AC 1 ms 3616 KiB
sample_03.txt AC 1 ms 3568 KiB