Submission #1112670

#TimeUsernameProblemLanguageResultExecution timeMemory
1112670noyancanturkGift (IZhO18_nicegift)C++17
7 / 100
633 ms70648 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=a[curop.inds.back()]; 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...