# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
860854 | 2023-10-14T16:06:28 Z | alexdd | Gift (IZhO18_nicegift) | C++17 | 2000 ms | 388076 KB |
#include<bits/stdc++.h> using namespace std; #define int long long int n,k; int a[1000005]; priority_queue<pair<int,int>> pq; vector<vector<int>> af; signed main() { ios_base::sync_with_stdio(0);cin.tie(0); cin>>n>>k; int sum=0; for(int i=1;i<=n;i++) { cin>>a[i]; sum += a[i]; pq.push({a[i],i}); } if(sum%k!=0) { cout<<-1; return 0; } while(!pq.empty()) { if((int)pq.size()<k) { cout<<-1; return 0; } vector<int> sc; //cout<<1<<" "; for(int i=0;i<k;i++) { sc.push_back(pq.top().second); a[sc.back()]--; //cout<<sc.back()<<" "; pq.pop(); } //cout<<"\n"; for(auto x:sc) if(a[x]>0) pq.push({a[x],x}); af.push_back(sc); } cout<<af.size()<<"\n"; for(int i=0;i<(int)af.size();i++) { cout<<1<<" "; for(int j=0;j<af[i].size();j++) cout<<af[i][j]<<" "; cout<<"\n"; } return 0; } /** 4 2 2 3 3 2 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | n=4 |
2 | Correct | 0 ms | 348 KB | n=3 |
3 | Correct | 0 ms | 348 KB | n=3 |
4 | Correct | 0 ms | 348 KB | n=4 |
5 | Correct | 0 ms | 348 KB | n=4 |
6 | Correct | 0 ms | 348 KB | n=2 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | n=4 |
2 | Correct | 0 ms | 348 KB | n=3 |
3 | Correct | 0 ms | 348 KB | n=3 |
4 | Correct | 0 ms | 348 KB | n=4 |
5 | Correct | 0 ms | 348 KB | n=4 |
6 | Correct | 0 ms | 348 KB | n=2 |
7 | Correct | 0 ms | 348 KB | n=5 |
8 | Correct | 2 ms | 1116 KB | n=8 |
9 | Correct | 5 ms | 1428 KB | n=14 |
10 | Correct | 3 ms | 1116 KB | n=11 |
11 | Correct | 29 ms | 6908 KB | n=50000 |
12 | Correct | 24 ms | 6868 KB | n=50000 |
13 | Correct | 16 ms | 3340 KB | n=10 |
14 | Correct | 19 ms | 3084 KB | n=685 |
15 | Correct | 20 ms | 3344 KB | n=623 |
16 | Correct | 11 ms | 2068 KB | n=973 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | n=4 |
2 | Correct | 0 ms | 348 KB | n=3 |
3 | Correct | 0 ms | 348 KB | n=3 |
4 | Correct | 0 ms | 348 KB | n=4 |
5 | Correct | 0 ms | 348 KB | n=4 |
6 | Correct | 0 ms | 348 KB | n=2 |
7 | Correct | 0 ms | 348 KB | n=5 |
8 | Correct | 2 ms | 1116 KB | n=8 |
9 | Correct | 5 ms | 1428 KB | n=14 |
10 | Correct | 3 ms | 1116 KB | n=11 |
11 | Correct | 29 ms | 6908 KB | n=50000 |
12 | Correct | 24 ms | 6868 KB | n=50000 |
13 | Correct | 16 ms | 3340 KB | n=10 |
14 | Correct | 19 ms | 3084 KB | n=685 |
15 | Correct | 20 ms | 3344 KB | n=623 |
16 | Correct | 11 ms | 2068 KB | n=973 |
17 | Correct | 20 ms | 2560 KB | n=989 |
18 | Correct | 9 ms | 1372 KB | n=563 |
19 | Correct | 14 ms | 1628 KB | n=592 |
20 | Correct | 16 ms | 1628 KB | n=938 |
21 | Correct | 12 ms | 1440 KB | n=747 |
22 | Correct | 16 ms | 1484 KB | n=991 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2078 ms | 388076 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | n=4 |
2 | Correct | 0 ms | 348 KB | n=3 |
3 | Correct | 0 ms | 348 KB | n=3 |
4 | Correct | 0 ms | 348 KB | n=4 |
5 | Correct | 0 ms | 348 KB | n=4 |
6 | Correct | 0 ms | 348 KB | n=2 |
7 | Correct | 0 ms | 348 KB | n=5 |
8 | Correct | 2 ms | 1116 KB | n=8 |
9 | Correct | 5 ms | 1428 KB | n=14 |
10 | Correct | 3 ms | 1116 KB | n=11 |
11 | Correct | 29 ms | 6908 KB | n=50000 |
12 | Correct | 24 ms | 6868 KB | n=50000 |
13 | Correct | 16 ms | 3340 KB | n=10 |
14 | Correct | 19 ms | 3084 KB | n=685 |
15 | Correct | 20 ms | 3344 KB | n=623 |
16 | Correct | 11 ms | 2068 KB | n=973 |
17 | Correct | 20 ms | 2560 KB | n=989 |
18 | Correct | 9 ms | 1372 KB | n=563 |
19 | Correct | 14 ms | 1628 KB | n=592 |
20 | Correct | 16 ms | 1628 KB | n=938 |
21 | Correct | 12 ms | 1440 KB | n=747 |
22 | Correct | 16 ms | 1484 KB | n=991 |
23 | Execution timed out | 2078 ms | 388076 KB | Time limit exceeded |
24 | Halted | 0 ms | 0 KB | - |