# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
341310 | 2020-12-29T12:55:19 Z | _ani | Gift (IZhO18_nicegift) | C++17 | 1032 ms | 73524 KB |
#include <iostream> #include <algorithm> #include <vector> #include <queue> using namespace std; using ll = long long; const int N = 1'000'002; pair<ll,int> a[N]; priority_queue<pair<ll, int>> q; vector<pair<ll, vector<int>>>ans; int main() { int n, k; cin >> n >> k; for (int i = 0; i < n; i++) { ll x; cin >> x; q.push({ x, i }); } while (!q.empty()) { vector<int> cur; if (q.size() < k) { cout << -1; return 0; } for (int i = 0; i < k; i++) { a[i] = q.top(); cur.push_back(a[i].second); q.pop(); } for (int i = 0; i < k - 1; i++) { a[i].first -= a[k - 1].first; if (a[i].first)q.push(a[i]); } ans.push_back({ a[k - 1].first,cur }); } cout << ans.size() << '\n'; for (auto b: ans) { cout << b.first << ' '; sort(b.second.begin(), b.second.end()); for (auto x : b.second) cout << x + 1 << ' '; cout << '\n'; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | n=4 |
2 | Correct | 1 ms | 384 KB | n=3 |
3 | Correct | 1 ms | 364 KB | n=3 |
4 | Correct | 1 ms | 364 KB | n=4 |
5 | Correct | 1 ms | 364 KB | n=4 |
6 | Correct | 1 ms | 364 KB | n=2 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | n=4 |
2 | Correct | 1 ms | 384 KB | n=3 |
3 | Correct | 1 ms | 364 KB | n=3 |
4 | Correct | 1 ms | 364 KB | n=4 |
5 | Correct | 1 ms | 364 KB | n=4 |
6 | Correct | 1 ms | 364 KB | n=2 |
7 | Correct | 1 ms | 364 KB | n=5 |
8 | Correct | 1 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 | 1 ms | 364 KB | n=4 |
2 | Correct | 1 ms | 384 KB | n=3 |
3 | Correct | 1 ms | 364 KB | n=3 |
4 | Correct | 1 ms | 364 KB | n=4 |
5 | Correct | 1 ms | 364 KB | n=4 |
6 | Correct | 1 ms | 364 KB | n=2 |
7 | Correct | 1 ms | 364 KB | n=5 |
8 | Correct | 1 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 | 1032 ms | 73524 KB | n=1000000 |
2 | Correct | 654 ms | 43060 KB | n=666666 |
3 | Correct | 376 ms | 22600 KB | n=400000 |
4 | Incorrect | 213 ms | 12668 KB | Jury has the answer but participant has not |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | n=4 |
2 | Correct | 1 ms | 384 KB | n=3 |
3 | Correct | 1 ms | 364 KB | n=3 |
4 | Correct | 1 ms | 364 KB | n=4 |
5 | Correct | 1 ms | 364 KB | n=4 |
6 | Correct | 1 ms | 364 KB | n=2 |
7 | Correct | 1 ms | 364 KB | n=5 |
8 | Correct | 1 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 | - |