Submission #1112674

#TimeUsernameProblemLanguageResultExecution timeMemory
1112674noyancanturkGift (IZhO18_nicegift)C++17
30 / 100
2074 ms420824 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define pb push_back using pii=pair<int,int>; const int lim=1e5+100; struct op{ int val; vector<int>inds; }; signed main(){ int n,k; cin>>n>>k; int a[n]; priority_queue<pii>pq; for(int i=0;i<n;i++)cin>>a[i],pq.push({a[i],i}); vector<op>ops; while(pq.size()){ op curop; while(curop.inds.size()<k){ if(!pq.size()){ cout<<-1; return 0; } curop.inds.pb(pq.top().second); pq.pop(); } curop.val=1; for(int i:curop.inds){ a[i]-=curop.val; if(a[i]){ pq.push({a[i],i}); } } ops.pb(curop); } cout<<ops.size()<<'\n'; for(op&p:ops){ cout<<p.val<<' '; for(int i:p.inds){ cout<<i+1<<' '; } cout<<'\n'; } }

Compilation message (stderr)

nicegift.cpp: In function 'int main()':
nicegift.cpp:22:28: 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]
   22 |     while(curop.inds.size()<k){
      |           ~~~~~~~~~~~~~~~~~^~
#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...