# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
334448 | 2020-12-09T07:29:03 Z | juggernaut | Gift (IZhO18_nicegift) | C++14 | 273 ms | 8720 KB |
#include<bits/stdc++.h> using namespace std; int n,k,mx,sum; priority_queue<pair<int,int>>q; int main(){ scanf("%d%d",&n,&k); for(int i=1;i<=n;i++){ int x; scanf("%d",&x); q.push({x,i}); mx=max(mx,x); sum+=x; } if(sum%k!=0||(mx<<1)>sum)return puts("-1"),0; vector<vector<int>>ans; while(!q.empty()){ vector<int>v; stack<pair<int,int>>temp; for(int i=0;i<k;i++){ temp.push(q.top()); q.pop(); v.push_back(temp.top().second); if(temp.top().first<2)temp.pop(); else temp.top().first--; } while(!temp.empty()){ q.push(temp.top()); temp.pop(); } ans.push_back(v); } printf("%d",(int)ans.size()); for(auto v:ans){ printf("\n1"); for(auto to:v)printf(" %d",to); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 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 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 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 | Correct | 15 ms | 1192 KB | n=14 |
10 | Correct | 9 ms | 1004 KB | n=11 |
11 | Correct | 56 ms | 4316 KB | n=50000 |
12 | Correct | 42 ms | 4188 KB | n=50000 |
13 | Correct | 52 ms | 3360 KB | n=10 |
14 | Correct | 43 ms | 3104 KB | n=685 |
15 | Correct | 31 ms | 3380 KB | n=623 |
16 | Correct | 17 ms | 1956 KB | n=973 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 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 | Correct | 15 ms | 1192 KB | n=14 |
10 | Correct | 9 ms | 1004 KB | n=11 |
11 | Correct | 56 ms | 4316 KB | n=50000 |
12 | Correct | 42 ms | 4188 KB | n=50000 |
13 | Correct | 52 ms | 3360 KB | n=10 |
14 | Correct | 43 ms | 3104 KB | n=685 |
15 | Correct | 31 ms | 3380 KB | n=623 |
16 | Correct | 17 ms | 1956 KB | n=973 |
17 | Correct | 44 ms | 2468 KB | n=989 |
18 | Correct | 12 ms | 1004 KB | n=563 |
19 | Correct | 19 ms | 1388 KB | n=592 |
20 | Correct | 27 ms | 1388 KB | n=938 |
21 | Correct | 15 ms | 1132 KB | n=747 |
22 | Correct | 17 ms | 1132 KB | n=991 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 273 ms | 8720 KB | Jury has the answer but participant has not |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 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 | Correct | 15 ms | 1192 KB | n=14 |
10 | Correct | 9 ms | 1004 KB | n=11 |
11 | Correct | 56 ms | 4316 KB | n=50000 |
12 | Correct | 42 ms | 4188 KB | n=50000 |
13 | Correct | 52 ms | 3360 KB | n=10 |
14 | Correct | 43 ms | 3104 KB | n=685 |
15 | Correct | 31 ms | 3380 KB | n=623 |
16 | Correct | 17 ms | 1956 KB | n=973 |
17 | Correct | 44 ms | 2468 KB | n=989 |
18 | Correct | 12 ms | 1004 KB | n=563 |
19 | Correct | 19 ms | 1388 KB | n=592 |
20 | Correct | 27 ms | 1388 KB | n=938 |
21 | Correct | 15 ms | 1132 KB | n=747 |
22 | Correct | 17 ms | 1132 KB | n=991 |
23 | Incorrect | 273 ms | 8720 KB | Jury has the answer but participant has not |
24 | Halted | 0 ms | 0 KB | - |