# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1112670 | noyancanturk | Gift (IZhO18_nicegift) | C++17 | 633 ms | 70648 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |