# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1060407 | 2024-08-15T13:56:42 Z | Jarif_Rahman | Gift (IZhO18_nicegift) | C++17 | 321 ms | 70316 KB |
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; vector<ll> A(n); for(ll &x: A) cin >> x; priority_queue<pair<ll, int>> pq; for(int i = 0; i < n; i++) pq.push({A[i], i}); vector<pair<ll, vector<int>>> ans; while(pq.size() >= k){ vector<int> cur; for(int i = 0; i < k; i++) cur.push_back(pq.top().second), pq.pop(); ll lim = 0; //if(!pq.empty()) lim = pq.top().first-1; ll mn = 1e18+5; for(int x: cur) mn = min(mn, A[x]-lim); for(int x: cur) A[x]-=mn; ans.push_back({mn, cur}); for(int x: cur) if(A[x]) pq.push({A[x], x}); } if(pq.size() != 0){ cout << "-1\n"; exit(0); } cout << ans.size() << "\n"; for(auto [x, v]: ans){ cout << x << " "; for(int i: v) cout << i+1 << " "; cout << "\n"; } }
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 | 344 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 | 344 KB | n=2 |
7 | Correct | 1 ms | 344 KB | n=5 |
8 | Correct | 0 ms | 344 KB | n=8 |
9 | Incorrect | 0 ms | 348 KB | Jury has the answer but participant has not |
10 | 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 | 344 KB | n=2 |
7 | Correct | 1 ms | 344 KB | n=5 |
8 | Correct | 0 ms | 344 KB | n=8 |
9 | Incorrect | 0 ms | 348 KB | Jury has the answer but participant has not |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 321 ms | 70316 KB | n=1000000 |
2 | Correct | 204 ms | 48156 KB | n=666666 |
3 | Correct | 116 ms | 26300 KB | n=400000 |
4 | Incorrect | 61 ms | 17092 KB | Jury has the answer but participant has not |
5 | 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 | 344 KB | n=2 |
7 | Correct | 1 ms | 344 KB | n=5 |
8 | Correct | 0 ms | 344 KB | n=8 |
9 | Incorrect | 0 ms | 348 KB | Jury has the answer but participant has not |
10 | Halted | 0 ms | 0 KB | - |