# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1112674 | 2024-11-14T14:31:03 Z | noyancanturk | Gift (IZhO18_nicegift) | C++17 | 2000 ms | 420824 KB |
#include<bits/stdc++.h> using namespace std; #define int long long #define pb push_back using pii=pair<int,int>; const int lim=1e5+100; struct op{ int val; vector<int>inds; }; signed main(){ int n,k; cin>>n>>k; int a[n]; priority_queue<pii>pq; for(int i=0;i<n;i++)cin>>a[i],pq.push({a[i],i}); vector<op>ops; while(pq.size()){ op curop; while(curop.inds.size()<k){ if(!pq.size()){ cout<<-1; return 0; } curop.inds.pb(pq.top().second); pq.pop(); } curop.val=1; for(int i:curop.inds){ a[i]-=curop.val; if(a[i]){ pq.push({a[i],i}); } } ops.pb(curop); } cout<<ops.size()<<'\n'; for(op&p:ops){ cout<<p.val<<' '; for(int i:p.inds){ cout<<i+1<<' '; } cout<<'\n'; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | n=4 |
2 | Correct | 1 ms | 336 KB | n=3 |
3 | Correct | 1 ms | 336 KB | n=3 |
4 | Correct | 1 ms | 336 KB | n=4 |
5 | Correct | 1 ms | 336 KB | n=4 |
6 | Correct | 1 ms | 336 KB | n=2 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | n=4 |
2 | Correct | 1 ms | 336 KB | n=3 |
3 | Correct | 1 ms | 336 KB | n=3 |
4 | Correct | 1 ms | 336 KB | n=4 |
5 | Correct | 1 ms | 336 KB | n=4 |
6 | Correct | 1 ms | 336 KB | n=2 |
7 | Correct | 1 ms | 336 KB | n=5 |
8 | Correct | 2 ms | 972 KB | n=8 |
9 | Correct | 5 ms | 1224 KB | n=14 |
10 | Correct | 6 ms | 1228 KB | n=11 |
11 | Correct | 32 ms | 5372 KB | n=50000 |
12 | Correct | 30 ms | 5568 KB | n=50000 |
13 | Correct | 19 ms | 3776 KB | n=10 |
14 | Correct | 20 ms | 3524 KB | n=685 |
15 | Correct | 21 ms | 3776 KB | n=623 |
16 | Correct | 14 ms | 2244 KB | n=973 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | n=4 |
2 | Correct | 1 ms | 336 KB | n=3 |
3 | Correct | 1 ms | 336 KB | n=3 |
4 | Correct | 1 ms | 336 KB | n=4 |
5 | Correct | 1 ms | 336 KB | n=4 |
6 | Correct | 1 ms | 336 KB | n=2 |
7 | Correct | 1 ms | 336 KB | n=5 |
8 | Correct | 2 ms | 972 KB | n=8 |
9 | Correct | 5 ms | 1224 KB | n=14 |
10 | Correct | 6 ms | 1228 KB | n=11 |
11 | Correct | 32 ms | 5372 KB | n=50000 |
12 | Correct | 30 ms | 5568 KB | n=50000 |
13 | Correct | 19 ms | 3776 KB | n=10 |
14 | Correct | 20 ms | 3524 KB | n=685 |
15 | Correct | 21 ms | 3776 KB | n=623 |
16 | Correct | 14 ms | 2244 KB | n=973 |
17 | Correct | 20 ms | 2748 KB | n=989 |
18 | Correct | 10 ms | 1228 KB | n=563 |
19 | Correct | 16 ms | 1740 KB | n=592 |
20 | Correct | 15 ms | 1740 KB | n=938 |
21 | Correct | 11 ms | 1548 KB | n=747 |
22 | Correct | 13 ms | 1484 KB | n=991 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2074 ms | 420824 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | n=4 |
2 | Correct | 1 ms | 336 KB | n=3 |
3 | Correct | 1 ms | 336 KB | n=3 |
4 | Correct | 1 ms | 336 KB | n=4 |
5 | Correct | 1 ms | 336 KB | n=4 |
6 | Correct | 1 ms | 336 KB | n=2 |
7 | Correct | 1 ms | 336 KB | n=5 |
8 | Correct | 2 ms | 972 KB | n=8 |
9 | Correct | 5 ms | 1224 KB | n=14 |
10 | Correct | 6 ms | 1228 KB | n=11 |
11 | Correct | 32 ms | 5372 KB | n=50000 |
12 | Correct | 30 ms | 5568 KB | n=50000 |
13 | Correct | 19 ms | 3776 KB | n=10 |
14 | Correct | 20 ms | 3524 KB | n=685 |
15 | Correct | 21 ms | 3776 KB | n=623 |
16 | Correct | 14 ms | 2244 KB | n=973 |
17 | Correct | 20 ms | 2748 KB | n=989 |
18 | Correct | 10 ms | 1228 KB | n=563 |
19 | Correct | 16 ms | 1740 KB | n=592 |
20 | Correct | 15 ms | 1740 KB | n=938 |
21 | Correct | 11 ms | 1548 KB | n=747 |
22 | Correct | 13 ms | 1484 KB | n=991 |
23 | Execution timed out | 2074 ms | 420824 KB | Time limit exceeded |
24 | Halted | 0 ms | 0 KB | - |