# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
338540 | 2020-12-23T10:49:20 Z | boykut | Gift (IZhO18_nicegift) | C++14 | 516 ms | 66856 KB |
#include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; vector <int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } priority_queue <pair <int, int>> q; for (int i = 0; i < n; i++) { q.push({a[i], 1+i}); } vector <vector <int>> res; while (!q.empty()) { if (q.size() >= k) { vector <pair <int, int> > vec; for (int i = 0; i < k; i++) { vec.push_back(q.top()); q.pop(); } res.push_back({vec.back().first}); for (int i = 0; i < k; i++) { res[res.size()-1].push_back(vec[i].second); vec[i].first -= vec.back().first; } for (int i = 0; i < k; i++) { if (vec[i].first > 0) q.push(vec[i]); } } else if (q.size() > 0 && q.size() < k) { return cout << "-1\n", 0; } } cout << res.size() << '\n'; for (int i = 0; i < res.size(); i++) { for (int j = 0; j < res[i].size(); j++) { cout << res[i][j] << ' '; } cout << '\n'; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | n=4 |
2 | Correct | 0 ms | 364 KB | n=3 |
3 | Correct | 1 ms | 364 KB | n=3 |
4 | Correct | 1 ms | 364 KB | n=4 |
5 | Correct | 0 ms | 364 KB | n=4 |
6 | Correct | 1 ms | 364 KB | n=2 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | n=4 |
2 | Correct | 0 ms | 364 KB | n=3 |
3 | Correct | 1 ms | 364 KB | n=3 |
4 | Correct | 1 ms | 364 KB | n=4 |
5 | Correct | 0 ms | 364 KB | n=4 |
6 | Correct | 1 ms | 364 KB | n=2 |
7 | Correct | 0 ms | 364 KB | n=5 |
8 | Correct | 0 ms | 364 KB | n=8 |
9 | Incorrect | 1 ms | 364 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 | 364 KB | n=4 |
2 | Correct | 0 ms | 364 KB | n=3 |
3 | Correct | 1 ms | 364 KB | n=3 |
4 | Correct | 1 ms | 364 KB | n=4 |
5 | Correct | 0 ms | 364 KB | n=4 |
6 | Correct | 1 ms | 364 KB | n=2 |
7 | Correct | 0 ms | 364 KB | n=5 |
8 | Correct | 0 ms | 364 KB | n=8 |
9 | Incorrect | 1 ms | 364 KB | Jury has the answer but participant has not |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 516 ms | 66856 KB | Jury has the answer but participant has not |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | n=4 |
2 | Correct | 0 ms | 364 KB | n=3 |
3 | Correct | 1 ms | 364 KB | n=3 |
4 | Correct | 1 ms | 364 KB | n=4 |
5 | Correct | 0 ms | 364 KB | n=4 |
6 | Correct | 1 ms | 364 KB | n=2 |
7 | Correct | 0 ms | 364 KB | n=5 |
8 | Correct | 0 ms | 364 KB | n=8 |
9 | Incorrect | 1 ms | 364 KB | Jury has the answer but participant has not |
10 | Halted | 0 ms | 0 KB | - |