Submission #334446

#TimeUsernameProblemLanguageResultExecution timeMemory
334446juggernautGift (IZhO18_nicegift)C++14
0 / 100
2054 ms11604 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...