Submission #72369138


Source Code Expand

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

int n,k,x;
vector<int> a;
vector<int> b;
priority_queue<pair<int,pair<int,int>>, vector<pair<int,pair<int,int>>>, greater<>> pq;
vector<int> diffs;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    
    cin>>n>>k>>x;
    a.resize(n);
    for(int i=0;i<n;i++)cin>>a[i];
    
    sort(a.begin(),a.end(),greater<>());
    int base=k*a[0];
    
    b.resize(n-1);
    for(int i=0;i<n-1;i++)b[i]=a[i]-a[i+1];
    
    diffs.push_back(0);
    if(n>1&&k>0){
        pq.push({b[0],{0,1}});
    }
    
    while(diffs.size()<x&&!pq.empty()){
        auto [val,state]=pq.top();
        pq.pop();
        auto [id,cnt]=state;
        
        diffs.push_back(val);
        if(cnt<k){
            pq.push({val+b[id],{id,cnt+1}});
        }
        
        if(id+1<n-1){
            pq.push({val+b[id+1],{id+1,1}});
        }
    }
    for(int i=0;i<x;i++){
        int idx=min(i,(int)diffs.size()-1);
        cout<<base-diffs[idx]<<'\n';
    }
    return 0;
}

Submission Info

Submission Time
Task E - Cookies
User kac17
Language C++23 (GCC 15.2.0)
Score 0
Code Size 1115 Byte
Status WA
Exec Time 20 ms
Memory 7272 KiB

Compile Error

./Main.cpp: In function 'int main()':
./Main.cpp:31:23: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   31 |     while(diffs.size()<x&&!pq.empty()){
      |           ~~~~~~~~~~~~^~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 450
Status
AC × 3
AC × 15
WA × 19
Set Name Test Cases
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
Case Name Status Exec Time Memory
hand_01.txt AC 1 ms 3512 KiB
hand_02.txt AC 1 ms 3452 KiB
hand_03.txt AC 1 ms 3644 KiB
random_01.txt WA 10 ms 4372 KiB
random_02.txt WA 10 ms 4656 KiB
random_03.txt AC 14 ms 7208 KiB
random_04.txt AC 13 ms 7164 KiB
random_05.txt AC 12 ms 7120 KiB
random_06.txt AC 13 ms 7160 KiB
random_07.txt WA 1 ms 3596 KiB
random_08.txt WA 1 ms 3524 KiB
random_09.txt AC 16 ms 7240 KiB
random_10.txt AC 15 ms 7252 KiB
random_11.txt AC 15 ms 7244 KiB
random_12.txt AC 15 ms 7224 KiB
random_13.txt WA 18 ms 7116 KiB
random_14.txt WA 19 ms 7272 KiB
random_15.txt WA 19 ms 6996 KiB
random_16.txt WA 20 ms 7204 KiB
random_17.txt WA 18 ms 7148 KiB
random_18.txt WA 1 ms 3472 KiB
random_19.txt WA 19 ms 7236 KiB
random_20.txt AC 1 ms 3596 KiB
random_21.txt WA 18 ms 7160 KiB
random_22.txt WA 19 ms 7068 KiB
random_23.txt WA 20 ms 7164 KiB
random_24.txt WA 17 ms 7120 KiB
random_25.txt WA 15 ms 7116 KiB
random_26.txt WA 18 ms 7144 KiB
random_27.txt WA 19 ms 7168 KiB
random_28.txt WA 13 ms 5120 KiB
sample_01.txt AC 1 ms 3544 KiB
sample_02.txt AC 1 ms 3676 KiB
sample_03.txt AC 1 ms 3596 KiB