Submission #340529

#TimeUsernameProblemLanguageResultExecution timeMemory
340529scalesGift (IZhO18_nicegift)C++17
30 / 100
214 ms32364 KiB
#include <bits/stdc++.h> /*#ifndef LOCAL_RUN #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("fast-math") #pragma GCC target("avx2,tune=native") #endif*/ using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); long long t,i,j,dno,x,y,z,w,m,k,n,x1,y1,tip,p,l,r,sum,maxi,kol,v; cin>>n; cin>>k; vector<pair<long long,long long> > a(n); sum=0; for(i=0;i<n;i++) { cin>>a[i].first; sum=sum+a[i].first; a[i].second=i+1; } sort(a.begin(),a.end()); /*for(i=0;i<n;i++) { cout<<a[i].first<<" "<<a[i].second<<endl; }*/ if( ((sum%k)!=0) || a[n-1].first>(sum/k)) { cout<<-1<<endl; } else { cout<<sum/k<<endl; vector< vector<long long> > viv(sum/k); priority_queue<pair<long long, long long> > q; queue <pair<long long, long long> > h; for(i=0;i<n;i++) { q.push({a[i].first,a[i].second}); } kol=0; l=0; while(!q.empty()) { x=q.top().first; y=q.top().second; //cout<<"x="<<x<<endl; x--; viv[l].push_back(y); kol++; if(x!=0) { h.push({x,y}); } q.pop(); if(kol==k) { kol=0; l++; while(!h.empty()) { q.push(h.front()); h.pop(); } } } for(i=0;i<sum/k;i++) { cout<<1<<" "; for(j=0;j<k;j++) { cout<<viv[i][j]<<" "; } cout<<endl; } } return 0; }

Compilation message (stderr)

nicegift.cpp: In function 'int main()':
nicegift.cpp:15:16: warning: unused variable 't' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,y1,tip,p,l,r,sum,maxi,kol,v;
      |                ^
nicegift.cpp:15:22: warning: unused variable 'dno' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,y1,tip,p,l,r,sum,maxi,kol,v;
      |                      ^~~
nicegift.cpp:15:30: warning: unused variable 'z' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,y1,tip,p,l,r,sum,maxi,kol,v;
      |                              ^
nicegift.cpp:15:32: warning: unused variable 'w' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,y1,tip,p,l,r,sum,maxi,kol,v;
      |                                ^
nicegift.cpp:15:34: warning: unused variable 'm' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,y1,tip,p,l,r,sum,maxi,kol,v;
      |                                  ^
nicegift.cpp:15:40: warning: unused variable 'x1' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,y1,tip,p,l,r,sum,maxi,kol,v;
      |                                        ^~
nicegift.cpp:15:43: warning: unused variable 'y1' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,y1,tip,p,l,r,sum,maxi,kol,v;
      |                                           ^~
nicegift.cpp:15:46: warning: unused variable 'tip' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,y1,tip,p,l,r,sum,maxi,kol,v;
      |                                              ^~~
nicegift.cpp:15:50: warning: unused variable 'p' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,y1,tip,p,l,r,sum,maxi,kol,v;
      |                                                  ^
nicegift.cpp:15:54: warning: unused variable 'r' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,y1,tip,p,l,r,sum,maxi,kol,v;
      |                                                      ^
nicegift.cpp:15:60: warning: unused variable 'maxi' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,y1,tip,p,l,r,sum,maxi,kol,v;
      |                                                            ^~~~
nicegift.cpp:15:69: warning: unused variable 'v' [-Wunused-variable]
   15 |      long long t,i,j,dno,x,y,z,w,m,k,n,x1,y1,tip,p,l,r,sum,maxi,kol,v;
      |                                                                     ^
#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...