# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
881301 | 2023-12-01T04:20:56 Z | dimashhh | Gift (IZhO18_nicegift) | C++17 | 569 ms | 192672 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e6 + 1; #define int long long int n,k; ll a[N]; set<pair<ll,ll>> st; vector<pair<vector<int>,int>> res(N * 3); void test(){ cin >> n >> k; for(int i = 1;i <= n;i++){ cin >> a[i]; st.insert({a[i],i}); } int it = 1; while(!st.empty()){ if((int)(it - 1) * k > 3e6||st.size() < k){ cout << -1 << '\n'; return; } vector<int> f; int oo; for(int i = 1;i <= k;i++){ auto [x,y] = *st.rbegin(); st.erase({x,y}); oo = x; f.push_back(y); } res[it] = {f,oo}; it++; for(auto j:f){ a[j] -= oo; if(a[j]){ st.insert({a[j],j}); } } } cout << it - 1 << '\n'; for(int f = 1;f < it;f++){ cout << res[f].second << ' '; for(auto j:res[f].first) cout << j << ' '; cout << '\n'; } } main(){ ios_base::sync_with_stdio(0);cin.tie(0); int T = 1; // cin >> T; while(T--) test(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 94232 KB | n=4 |
2 | Correct | 22 ms | 94300 KB | n=3 |
3 | Correct | 22 ms | 94296 KB | n=3 |
4 | Correct | 20 ms | 94296 KB | n=4 |
5 | Correct | 21 ms | 94296 KB | n=4 |
6 | Correct | 23 ms | 94296 KB | n=2 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 94232 KB | n=4 |
2 | Correct | 22 ms | 94300 KB | n=3 |
3 | Correct | 22 ms | 94296 KB | n=3 |
4 | Correct | 20 ms | 94296 KB | n=4 |
5 | Correct | 21 ms | 94296 KB | n=4 |
6 | Correct | 23 ms | 94296 KB | n=2 |
7 | Correct | 21 ms | 94300 KB | n=5 |
8 | Correct | 21 ms | 94296 KB | n=8 |
9 | Incorrect | 20 ms | 94296 KB | Jury has the answer but participant has not |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 94232 KB | n=4 |
2 | Correct | 22 ms | 94300 KB | n=3 |
3 | Correct | 22 ms | 94296 KB | n=3 |
4 | Correct | 20 ms | 94296 KB | n=4 |
5 | Correct | 21 ms | 94296 KB | n=4 |
6 | Correct | 23 ms | 94296 KB | n=2 |
7 | Correct | 21 ms | 94300 KB | n=5 |
8 | Correct | 21 ms | 94296 KB | n=8 |
9 | Incorrect | 20 ms | 94296 KB | Jury has the answer but participant has not |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 569 ms | 192672 KB | n=1000000 |
2 | Correct | 393 ms | 159296 KB | n=666666 |
3 | Correct | 227 ms | 132944 KB | n=400000 |
4 | Incorrect | 134 ms | 120256 KB | Jury has the answer but participant has not |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 94232 KB | n=4 |
2 | Correct | 22 ms | 94300 KB | n=3 |
3 | Correct | 22 ms | 94296 KB | n=3 |
4 | Correct | 20 ms | 94296 KB | n=4 |
5 | Correct | 21 ms | 94296 KB | n=4 |
6 | Correct | 23 ms | 94296 KB | n=2 |
7 | Correct | 21 ms | 94300 KB | n=5 |
8 | Correct | 21 ms | 94296 KB | n=8 |
9 | Incorrect | 20 ms | 94296 KB | Jury has the answer but participant has not |
10 | Halted | 0 ms | 0 KB | - |