# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
957097 | 2024-04-03T01:32:00 Z | Darren0724 | Gift (IZhO18_nicegift) | C++17 | 2000 ms | 381124 KB |
#include <bits/stdc++.h> using namespace std; #define LCBorz ios_base::sync_with_stdio(false); cin.tie(0); #define int long long #define all(x) x.begin(), x.end() //#define endl '\n' const int N=200005; const int INF=1e18; const int mod=1e9+7; int32_t main() { LCBorz; int n,k;cin>>n>>k; vector<int> v(n+1); priority_queue<pair<int,int>> pq; int total=0; for(int i=1;i<=n;i++){ cin>>v[i]; pq.push({v[i],i}); total+=v[i]; } vector<vector<int>> ans; while(pq.size()>=k){ int mn=0; vector<int> t; for(int i=0;i<k;i++){ auto [a,b]=pq.top(); pq.pop(); mn=a; t.push_back(b); } int cost=1; for(int j:t){ v[j]-=cost; if(v[j]>0)pq.push({v[j],j}); } t.push_back(cost); reverse(all(t)); ans.push_back(t); } if(pq.size()!=0){ cout<<-1<<endl; return 0; } cout<<ans.size()<<endl; for(auto v:ans){ for(int j:v){ cout<<j<<' '; } cout<<endl; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | n=4 |
2 | Correct | 0 ms | 348 KB | n=3 |
3 | Correct | 0 ms | 348 KB | n=3 |
4 | Correct | 1 ms | 348 KB | n=4 |
5 | Correct | 1 ms | 348 KB | n=4 |
6 | Correct | 0 ms | 348 KB | n=2 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | n=4 |
2 | Correct | 0 ms | 348 KB | n=3 |
3 | Correct | 0 ms | 348 KB | n=3 |
4 | Correct | 1 ms | 348 KB | n=4 |
5 | Correct | 1 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 | 21 ms | 1176 KB | n=14 |
10 | Correct | 13 ms | 920 KB | n=11 |
11 | Correct | 82 ms | 5064 KB | n=50000 |
12 | Correct | 84 ms | 5008 KB | n=50000 |
13 | Correct | 93 ms | 3536 KB | n=10 |
14 | Correct | 72 ms | 3072 KB | n=685 |
15 | Correct | 71 ms | 3320 KB | n=623 |
16 | Correct | 40 ms | 1904 KB | n=973 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | n=4 |
2 | Correct | 0 ms | 348 KB | n=3 |
3 | Correct | 0 ms | 348 KB | n=3 |
4 | Correct | 1 ms | 348 KB | n=4 |
5 | Correct | 1 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 | 21 ms | 1176 KB | n=14 |
10 | Correct | 13 ms | 920 KB | n=11 |
11 | Correct | 82 ms | 5064 KB | n=50000 |
12 | Correct | 84 ms | 5008 KB | n=50000 |
13 | Correct | 93 ms | 3536 KB | n=10 |
14 | Correct | 72 ms | 3072 KB | n=685 |
15 | Correct | 71 ms | 3320 KB | n=623 |
16 | Correct | 40 ms | 1904 KB | n=973 |
17 | Correct | 55 ms | 3188 KB | n=989 |
18 | Correct | 19 ms | 1360 KB | n=563 |
19 | Correct | 19 ms | 1884 KB | n=592 |
20 | Correct | 22 ms | 1836 KB | n=938 |
21 | Correct | 19 ms | 1372 KB | n=747 |
22 | Correct | 20 ms | 1628 KB | n=991 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2050 ms | 381124 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | n=4 |
2 | Correct | 0 ms | 348 KB | n=3 |
3 | Correct | 0 ms | 348 KB | n=3 |
4 | Correct | 1 ms | 348 KB | n=4 |
5 | Correct | 1 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 | 21 ms | 1176 KB | n=14 |
10 | Correct | 13 ms | 920 KB | n=11 |
11 | Correct | 82 ms | 5064 KB | n=50000 |
12 | Correct | 84 ms | 5008 KB | n=50000 |
13 | Correct | 93 ms | 3536 KB | n=10 |
14 | Correct | 72 ms | 3072 KB | n=685 |
15 | Correct | 71 ms | 3320 KB | n=623 |
16 | Correct | 40 ms | 1904 KB | n=973 |
17 | Correct | 55 ms | 3188 KB | n=989 |
18 | Correct | 19 ms | 1360 KB | n=563 |
19 | Correct | 19 ms | 1884 KB | n=592 |
20 | Correct | 22 ms | 1836 KB | n=938 |
21 | Correct | 19 ms | 1372 KB | n=747 |
22 | Correct | 20 ms | 1628 KB | n=991 |
23 | Execution timed out | 2050 ms | 381124 KB | Time limit exceeded |
24 | Halted | 0 ms | 0 KB | - |