Submission #1112670

# Submission time Handle Problem Language Result Execution time Memory
1112670 2024-11-14T14:26:57 Z noyancanturk Gift (IZhO18_nicegift) C++17
7 / 100
633 ms 70648 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()];
    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 336 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 336 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 Incorrect 1 ms 336 KB Jury has the answer but participant has not
10 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 336 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 Incorrect 1 ms 336 KB Jury has the answer but participant has not
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 633 ms 70648 KB n=1000000
2 Correct 467 ms 41476 KB n=666666
3 Correct 252 ms 27164 KB n=400000
4 Incorrect 139 ms 14936 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 336 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 Incorrect 1 ms 336 KB Jury has the answer but participant has not
10 Halted 0 ms 0 KB -