Submission #334446

# Submission time Handle Problem Language Result Execution time Memory
334446 2020-12-09T07:27:44 Z juggernaut Gift (IZhO18_nicegift) C++14
0 / 100
2000 ms 11604 KB
#include<bits/stdc++.h>
using namespace std;
int n,k,mx,sum;
priority_queue<pair<int,int>>q;
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        q.push({x,i});
        mx=max(mx,x);
        sum+=x;
    }
    if(sum%k!=0||(mx<<1)>sum)return puts("-1"),0;
    vector<vector<int>>ans;
    while(!q.empty()){
        vector<int>v;
        stack<pair<int,int>>temp;
        for(int i=0;i<k;i++){
            temp.push(q.top());
            q.pop();
            v.push_back(temp.top().second);
            if(temp.top().first<2)temp.pop();
        }
        while(!temp.empty()){
            q.push(temp.top());
            temp.pop();
        }
    }
    printf("%d",(int)ans.size());
    for(auto v:ans){
        printf("\n1");
        for(auto to:v)printf("%d ",to);
    }
}

Compilation message

nicegift.cpp: In function 'int main()':
nicegift.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    6 |     scanf("%d%d",&n,&k);
      |     ~~~~~^~~~~~~~~~~~~~
nicegift.cpp:9:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |         scanf("%d",&x);
      |         ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 2054 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2054 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2054 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 242 ms 11604 KB Jury has the answer but participant has not
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2054 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -