# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
93281 | 2019-01-07T11:59:27 Z | SamAnd | Gift (IZhO18_nicegift) | C++17 | 487 ms | 65328 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1000006; struct ban { int i; long long x; ban(){} ban(int i, long long x) { this->i = i; this->x = x; } }; bool operator<(const ban& a, const ban& b) { return a.x < b.x; } int n, k; long long a[N]; void solv1() { vector<vector<long long> > ans; priority_queue<ban> q; for (int i = 1; i <= n; ++i) q.push(ban(i, a[i])); bool z = false; while (1) { if (q.size() == 0) { z = true; break; } if (q.size() < k) break; vector<ban> v; for (int ii = 0; ii < k; ++ii) { v.push_back(q.top()); q.pop(); } long long minu = v[0].x; for (int i = 1; i < k; ++i) minu = min(minu, v[i].x); vector<long long> vv; vv.push_back(minu); for (int i = 0; i < k; ++i) { v[i].x -= minu; if (v[i].x) q.push(v[i]); vv.push_back(v[i].i); } ans.push_back(vv); } if (!z) { printf("-1\n"); return; } printf("%d\n", ans.size()); for (int i = 0; i < ans.size(); ++i) { for (int j = 0; j < ans[i].size(); ++j) printf("%lld ", ans[i][j]); printf("\n"); } } int main() { //freopen("input2.txt", "r", stdin); scanf("%d%d", &n, &k); for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]); solv1(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | n=4 |
2 | Correct | 2 ms | 252 KB | n=3 |
3 | Correct | 2 ms | 256 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 296 KB | n=4 |
6 | Correct | 2 ms | 376 KB | n=2 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | n=4 |
2 | Correct | 2 ms | 252 KB | n=3 |
3 | Correct | 2 ms | 256 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 296 KB | n=4 |
6 | Correct | 2 ms | 376 KB | n=2 |
7 | Correct | 2 ms | 376 KB | n=5 |
8 | Correct | 2 ms | 376 KB | n=8 |
9 | Incorrect | 2 ms | 376 KB | Jury has the answer but participant has not |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | n=4 |
2 | Correct | 2 ms | 252 KB | n=3 |
3 | Correct | 2 ms | 256 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 296 KB | n=4 |
6 | Correct | 2 ms | 376 KB | n=2 |
7 | Correct | 2 ms | 376 KB | n=5 |
8 | Correct | 2 ms | 376 KB | n=8 |
9 | Incorrect | 2 ms | 376 KB | Jury has the answer but participant has not |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 487 ms | 65328 KB | n=1000000 |
2 | Correct | 296 ms | 40736 KB | n=666666 |
3 | Correct | 172 ms | 23504 KB | n=400000 |
4 | Incorrect | 82 ms | 13684 KB | Jury has the answer but participant has not |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | n=4 |
2 | Correct | 2 ms | 252 KB | n=3 |
3 | Correct | 2 ms | 256 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 296 KB | n=4 |
6 | Correct | 2 ms | 376 KB | n=2 |
7 | Correct | 2 ms | 376 KB | n=5 |
8 | Correct | 2 ms | 376 KB | n=8 |
9 | Incorrect | 2 ms | 376 KB | Jury has the answer but participant has not |
10 | Halted | 0 ms | 0 KB | - |