Submission #1112684

# Submission time Handle Problem Language Result Execution time Memory
1112684 2024-11-14T14:59:32 Z noyancanturk Gift (IZhO18_nicegift) C++17
7 / 100
867 ms 108836 KB
#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()]-1;
    if(!curop.val)curop.val++;
    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

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 time Memory Grader output
1 Correct 1 ms 336 KB n=4
2 Correct 1 ms 336 KB n=3
3 Correct 1 ms 336 KB n=3
4 Correct 1 ms 504 KB n=4
5 Correct 1 ms 336 KB n=4
6 Correct 1 ms 336 KB n=2
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB n=4
2 Correct 1 ms 336 KB n=3
3 Correct 1 ms 336 KB n=3
4 Correct 1 ms 504 KB n=4
5 Correct 1 ms 336 KB n=4
6 Correct 1 ms 336 KB n=2
7 Correct 1 ms 336 KB n=5
8 Correct 1 ms 336 KB n=8
9 Correct 1 ms 336 KB n=14
10 Incorrect 1 ms 336 KB Jury has the answer but participant has not
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB n=4
2 Correct 1 ms 336 KB n=3
3 Correct 1 ms 336 KB n=3
4 Correct 1 ms 504 KB n=4
5 Correct 1 ms 336 KB n=4
6 Correct 1 ms 336 KB n=2
7 Correct 1 ms 336 KB n=5
8 Correct 1 ms 336 KB n=8
9 Correct 1 ms 336 KB n=14
10 Incorrect 1 ms 336 KB Jury has the answer but participant has not
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 867 ms 108836 KB n=1000000
2 Correct 562 ms 59416 KB n=666666
3 Correct 319 ms 31712 KB n=400000
4 Incorrect 190 ms 16284 KB Jury has the answer but participant has not
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB n=4
2 Correct 1 ms 336 KB n=3
3 Correct 1 ms 336 KB n=3
4 Correct 1 ms 504 KB n=4
5 Correct 1 ms 336 KB n=4
6 Correct 1 ms 336 KB n=2
7 Correct 1 ms 336 KB n=5
8 Correct 1 ms 336 KB n=8
9 Correct 1 ms 336 KB n=14
10 Incorrect 1 ms 336 KB Jury has the answer but participant has not
11 Halted 0 ms 0 KB -