# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
378708 | 2021-03-17T03:27:19 Z | jass921026 | Gift (IZhO18_nicegift) | C++14 | 542 ms | 70140 KB |
#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; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | n=4 |
2 | Correct | 1 ms | 364 KB | n=3 |
3 | Correct | 1 ms | 364 KB | n=3 |
4 | Correct | 1 ms | 364 KB | n=4 |
5 | Correct | 1 ms | 364 KB | n=4 |
6 | Correct | 1 ms | 364 KB | n=2 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | n=4 |
2 | Correct | 1 ms | 364 KB | n=3 |
3 | Correct | 1 ms | 364 KB | n=3 |
4 | Correct | 1 ms | 364 KB | n=4 |
5 | Correct | 1 ms | 364 KB | n=4 |
6 | Correct | 1 ms | 364 KB | n=2 |
7 | Correct | 1 ms | 364 KB | n=5 |
8 | Correct | 1 ms | 364 KB | n=8 |
9 | Incorrect | 1 ms | 364 KB | Jury has the answer but participant has not |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | n=4 |
2 | Correct | 1 ms | 364 KB | n=3 |
3 | Correct | 1 ms | 364 KB | n=3 |
4 | Correct | 1 ms | 364 KB | n=4 |
5 | Correct | 1 ms | 364 KB | n=4 |
6 | Correct | 1 ms | 364 KB | n=2 |
7 | Correct | 1 ms | 364 KB | n=5 |
8 | Correct | 1 ms | 364 KB | n=8 |
9 | Incorrect | 1 ms | 364 KB | Jury has the answer but participant has not |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 542 ms | 70140 KB | n=1000000 |
2 | Correct | 334 ms | 38972 KB | n=666666 |
3 | Correct | 238 ms | 21184 KB | n=400000 |
4 | Incorrect | 91 ms | 11392 KB | Jury has the answer but participant has not |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | n=4 |
2 | Correct | 1 ms | 364 KB | n=3 |
3 | Correct | 1 ms | 364 KB | n=3 |
4 | Correct | 1 ms | 364 KB | n=4 |
5 | Correct | 1 ms | 364 KB | n=4 |
6 | Correct | 1 ms | 364 KB | n=2 |
7 | Correct | 1 ms | 364 KB | n=5 |
8 | Correct | 1 ms | 364 KB | n=8 |
9 | Incorrect | 1 ms | 364 KB | Jury has the answer but participant has not |
10 | Halted | 0 ms | 0 KB | - |