| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 378730 | jass921026 | Gift (IZhO18_nicegift) | C++14 | 1234 ms | 141660 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.
// This is fake solution qq
#include<bits/stdc++.h>
using namespace std;
#define jizz ios_base::sync_with_stdio(false);cin.tie(NULL);
typedef long long ll;
typedef pair<ll,int> pii;
#define F first
#define S second
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define mkp make_pair
const int MAXN=1E6+10, MAX_OPS=3E6;
ll A[MAXN];
vector<ll> val;
vector<ll> tmp, tmp2;
vector<vector<ll> > idx;
priority_queue<pii> pq;
int main(){ jizz
    int n, k;
    cin>>n>>k;
    ll sum=0;
    for(int i=1;i<=n;i++){
        cin>>A[i];
        sum+=A[i];
        pq.push(mkp(A[i],i));
    }
    if(sum%k>0){
        cout<<"-1\n";
        return 0;
    }
    bool ok=true;
    for(int i=0;i*k<MAX_OPS;i++){
        tmp.clear();
        tmp2.clear();
        if(pq.size()<k){
            ok=false;
            break;
        }
        for(int j=0;j<k;j++){
            pii cur=pq.top();
            tmp.pb(cur.F);
            tmp2.pb(cur.S);
            pq.pop();
        }
        val.pb(1);
        idx.pb(tmp2);
        for(int j=0;j<k;j++){
            tmp[j]-=1;
            if(tmp[j]) pq.push(mkp(tmp[j],tmp2[j]));
        }
        if(pq.size()==0) break;
    }
    if(val.size()*k>MAX_OPS) ok=false;
    if(ok){
        cout<<val.size()<<"\n";
        for(int i=0;i<val.size();i++){
            cout<<val[i]<<" ";
            for(int j=0;j<k;j++){
                cout<<idx[i][j]<<" \n"[j==k-1];
            }
        }
    } else{
        cout<<"-1\n";
        return 0;
    }
    return 0;
}
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... | ||||
