# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40450 | 2018-02-01T15:09:41 Z | szawinis | Gift (IZhO18_nicegift) | C++14 | 201 ms | 27920 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1e6+1; int n, k, a[N]; vector<int> ls[N]; int main() { scanf("%d %d", &n, &k); int sum = 0; for(int i = 0; i < n; i++) scanf("%d", a+i), sum += a[i]; if(sum % k) printf("-1"), exit(0); priority_queue<pair<int,int> > pq; for(int i = 0; i < sum / k; i++) pq.emplace(k, i); for(int i = 0; i < n; i++) { unordered_set<int> mark; for(int j = 0; j < a[i]; j++) { assert(!pq.empty()); auto curr = pq.top(); pq.pop(); --curr.first; if(mark.count(curr.second)) printf("-1"), exit(0); ls[curr.second].push_back(i); pq.push(curr); mark.insert(curr.second); } } printf("%d\n", sum / k); for(int i = 0; i < sum / k; i++) { printf("%d ", ls[i].size()); for(int idx: ls[i]) printf("%d ", idx+1); printf("\n"); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 23 ms | 23800 KB | Taken too much stones from the heap |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 23 ms | 23800 KB | Taken too much stones from the heap |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 23 ms | 23800 KB | Taken too much stones from the heap |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 201 ms | 27920 KB | Not all heaps are empty in the end |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 23 ms | 23800 KB | Taken too much stones from the heap |
2 | Halted | 0 ms | 0 KB | - |