Submission #484823

# Submission time Handle Problem Language Result Execution time Memory
484823 2021-11-05T14:51:43 Z Ronin13 Gift (IZhO18_nicegift) C++14
0 / 100
59 ms 8608 KB
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
using namespace std;

void solve(){
    int n;cin>>n;
    int k;cin>>k;
    priority_queue<pii>q;
    int sum=0;
    for(int i=1;i<=n;i++){
        int x;cin>>x;
        q.push({x,i});
        sum+=x;
    }
    if(sum%k){
        cout<<-1;
        return;
    }
    if(q.top().f>sum/k){
        cout<<-1<<"\n";
        return;
    }
    while(!q.empty()){
        vector<pii>vec;
        int x=k;
        while(x--){
            pii a=q.top();
            vec.pb(a);
            q.pop();
        }
        cout<<1<<' ';
        for(pii to:vec){
            cout<<to.s<<' ';
            if(to.f>1)
            q.push({to.f-1,to.s});
        }
        cout<<"\n";
    }
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int test=1;//cin>>test;
    while(test--){
        solve();
        cout<<"\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 59 ms 8608 KB Jury has the answer but participant has not
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -