# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
726670 | 2023-04-19T08:47:04 Z | fdnfksd | Gift (IZhO18_nicegift) | C++14 | 140 ms | 21828 KB |
#include<bits/stdc++.h> #define TASKNAME "codeforce" #define pb push_back #define pli pair<int,int> #define fi first #define se second #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); using namespace std; using ll=long long; const ll maxN=2e6+10; const ll inf=1e18; const ll mod=1e9+7; ll n,k,a[maxN]; void solve() { cin >> n >> k; ll sum=0; for(int i=1;i<=n;i++) { cin >> a[i]; sum+=a[i]; } if(sum<=1e5) { priority_queue<pli> pq; for(int i=1;i<=n;i++) pq.push({a[i],i}); vector<pli> vc; vc.resize(k); vector<vector<ll>> ans; while(pq.size()>=k) { vector<ll> vd; vd.pb(1); for(int i=0;i<k;i++) { vc[i]=pq.top(); pq.pop(); vc[i].fi--; vd.pb(vc[i].se); } sum-=k; ans.pb(vd); for(int i=0;i<k;i++) { if(vc[i].fi>0) pq.push(vc[i]); } } if(sum==0) { cout << ans.size()<<'\n'; for(auto vec:ans) { for(auto zz:vec) cout << zz<<' '; cout << '\n'; } } else cout << -1; } } int main() { fastio //freopen(TASKNAME".INP","r",stdin); //freopen(TASKNAME".OUT","w",stdout); solve(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 212 KB | n=4 |
2 | Correct | 1 ms | 212 KB | n=3 |
3 | Correct | 1 ms | 212 KB | n=3 |
4 | Correct | 1 ms | 212 KB | n=4 |
5 | Correct | 4 ms | 212 KB | n=4 |
6 | Correct | 1 ms | 212 KB | n=2 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 212 KB | n=4 |
2 | Correct | 1 ms | 212 KB | n=3 |
3 | Correct | 1 ms | 212 KB | n=3 |
4 | Correct | 1 ms | 212 KB | n=4 |
5 | Correct | 4 ms | 212 KB | n=4 |
6 | Correct | 1 ms | 212 KB | n=2 |
7 | Correct | 1 ms | 212 KB | n=5 |
8 | Correct | 3 ms | 1000 KB | n=8 |
9 | Correct | 8 ms | 1168 KB | n=14 |
10 | Correct | 5 ms | 980 KB | n=11 |
11 | Correct | 33 ms | 4660 KB | n=50000 |
12 | Correct | 31 ms | 4628 KB | n=50000 |
13 | Correct | 23 ms | 3412 KB | n=10 |
14 | Correct | 24 ms | 3076 KB | n=685 |
15 | Correct | 28 ms | 3296 KB | n=623 |
16 | Correct | 16 ms | 1964 KB | n=973 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 212 KB | n=4 |
2 | Correct | 1 ms | 212 KB | n=3 |
3 | Correct | 1 ms | 212 KB | n=3 |
4 | Correct | 1 ms | 212 KB | n=4 |
5 | Correct | 4 ms | 212 KB | n=4 |
6 | Correct | 1 ms | 212 KB | n=2 |
7 | Correct | 1 ms | 212 KB | n=5 |
8 | Correct | 3 ms | 1000 KB | n=8 |
9 | Correct | 8 ms | 1168 KB | n=14 |
10 | Correct | 5 ms | 980 KB | n=11 |
11 | Correct | 33 ms | 4660 KB | n=50000 |
12 | Correct | 31 ms | 4628 KB | n=50000 |
13 | Correct | 23 ms | 3412 KB | n=10 |
14 | Correct | 24 ms | 3076 KB | n=685 |
15 | Correct | 28 ms | 3296 KB | n=623 |
16 | Correct | 16 ms | 1964 KB | n=973 |
17 | Correct | 25 ms | 3016 KB | n=989 |
18 | Correct | 27 ms | 1236 KB | n=563 |
19 | Correct | 16 ms | 1704 KB | n=592 |
20 | Correct | 23 ms | 1732 KB | n=938 |
21 | Correct | 14 ms | 1348 KB | n=747 |
22 | Correct | 16 ms | 1492 KB | n=991 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 140 ms | 21828 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 212 KB | n=4 |
2 | Correct | 1 ms | 212 KB | n=3 |
3 | Correct | 1 ms | 212 KB | n=3 |
4 | Correct | 1 ms | 212 KB | n=4 |
5 | Correct | 4 ms | 212 KB | n=4 |
6 | Correct | 1 ms | 212 KB | n=2 |
7 | Correct | 1 ms | 212 KB | n=5 |
8 | Correct | 3 ms | 1000 KB | n=8 |
9 | Correct | 8 ms | 1168 KB | n=14 |
10 | Correct | 5 ms | 980 KB | n=11 |
11 | Correct | 33 ms | 4660 KB | n=50000 |
12 | Correct | 31 ms | 4628 KB | n=50000 |
13 | Correct | 23 ms | 3412 KB | n=10 |
14 | Correct | 24 ms | 3076 KB | n=685 |
15 | Correct | 28 ms | 3296 KB | n=623 |
16 | Correct | 16 ms | 1964 KB | n=973 |
17 | Correct | 25 ms | 3016 KB | n=989 |
18 | Correct | 27 ms | 1236 KB | n=563 |
19 | Correct | 16 ms | 1704 KB | n=592 |
20 | Correct | 23 ms | 1732 KB | n=938 |
21 | Correct | 14 ms | 1348 KB | n=747 |
22 | Correct | 16 ms | 1492 KB | n=991 |
23 | Incorrect | 140 ms | 21828 KB | Unexpected end of file - int32 expected |
24 | Halted | 0 ms | 0 KB | - |