| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 378708 | jass921026 | Gift (IZhO18_nicegift) | C++14 | 542 ms | 70140 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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(tmp[k-1]);
        idx.pb(tmp2);
        for(int j=0;j<k;j++){
            tmp[j]-=tmp[k-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;
}
컴파일 시 표준 에러 (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... | ||||
