# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
133828 | 2019-07-21T13:31:59 Z | Kastanda | Gift (IZhO18_nicegift) | C++11 | 1251 ms | 73260 KB |
// ItnoE #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1000006; int n, k; ll SM, A[N]; vector < ll > R; priority_queue < pair < ll , int > > Pq; int main() { scanf("%d%d", &n, &k); for (int i = 1; i <= n; i ++) { scanf("%lld", &A[i]); Pq.push({A[i], i}); SM += A[i]; } if (SM % k || Pq.top().first > SM / k) return !printf("-1\n"); SM /= k; while (Pq.top().first) { vector < int > vec; for (int i = 0; i < k; i ++) vec.push_back(Pq.top().second), Pq.pop(); ll Mx = Pq.size() ? Pq.top().first : 0LL; ll X = min(A[vec.back()], SM - Mx); R.push_back(X); SM -= X; for (int i = 0; i < k; i ++) A[vec[i]] -= X, Pq.push({A[vec[i]], vec[i]}), R.push_back(vec[i]); } printf("%d\n", (int)R.size() / (k + 1)); for (int i = 0; i < (int)R.size(); i ++) { printf("%lld ", R[i]); if ((i + 1) % (k + 1) == 0) printf("\n"); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | n=4 |
2 | Correct | 2 ms | 376 KB | n=3 |
3 | Correct | 0 ms | 256 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 256 KB | n=4 |
6 | Correct | 2 ms | 256 KB | n=2 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | n=4 |
2 | Correct | 2 ms | 376 KB | n=3 |
3 | Correct | 0 ms | 256 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 256 KB | n=4 |
6 | Correct | 2 ms | 256 KB | n=2 |
7 | Correct | 2 ms | 252 KB | n=5 |
8 | Correct | 2 ms | 376 KB | n=8 |
9 | Correct | 2 ms | 376 KB | n=14 |
10 | Correct | 2 ms | 256 KB | n=11 |
11 | Correct | 32 ms | 3192 KB | n=50000 |
12 | Correct | 26 ms | 3180 KB | n=50000 |
13 | Correct | 2 ms | 376 KB | n=10 |
14 | Correct | 2 ms | 376 KB | n=685 |
15 | Correct | 2 ms | 376 KB | n=623 |
16 | Correct | 3 ms | 376 KB | n=973 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | n=4 |
2 | Correct | 2 ms | 376 KB | n=3 |
3 | Correct | 0 ms | 256 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 256 KB | n=4 |
6 | Correct | 2 ms | 256 KB | n=2 |
7 | Correct | 2 ms | 252 KB | n=5 |
8 | Correct | 2 ms | 376 KB | n=8 |
9 | Correct | 2 ms | 376 KB | n=14 |
10 | Correct | 2 ms | 256 KB | n=11 |
11 | Correct | 32 ms | 3192 KB | n=50000 |
12 | Correct | 26 ms | 3180 KB | n=50000 |
13 | Correct | 2 ms | 376 KB | n=10 |
14 | Correct | 2 ms | 376 KB | n=685 |
15 | Correct | 2 ms | 376 KB | n=623 |
16 | Correct | 3 ms | 376 KB | n=973 |
17 | Correct | 3 ms | 376 KB | n=989 |
18 | Correct | 2 ms | 312 KB | n=563 |
19 | Correct | 3 ms | 376 KB | n=592 |
20 | Correct | 3 ms | 376 KB | n=938 |
21 | Correct | 3 ms | 376 KB | n=747 |
22 | Correct | 3 ms | 376 KB | n=991 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 627 ms | 50236 KB | n=1000000 |
2 | Correct | 412 ms | 39204 KB | n=666666 |
3 | Correct | 230 ms | 21736 KB | n=400000 |
4 | Correct | 163 ms | 16516 KB | n=285714 |
5 | Correct | 12 ms | 1648 KB | n=20000 |
6 | Correct | 98 ms | 12124 KB | n=181818 |
7 | Correct | 7 ms | 1020 KB | n=10000 |
8 | Correct | 6 ms | 888 KB | n=6666 |
9 | Correct | 4 ms | 632 KB | n=4000 |
10 | Correct | 7 ms | 1048 KB | n=2857 |
11 | Correct | 4 ms | 504 KB | n=2000 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | n=4 |
2 | Correct | 2 ms | 376 KB | n=3 |
3 | Correct | 0 ms | 256 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 256 KB | n=4 |
6 | Correct | 2 ms | 256 KB | n=2 |
7 | Correct | 2 ms | 252 KB | n=5 |
8 | Correct | 2 ms | 376 KB | n=8 |
9 | Correct | 2 ms | 376 KB | n=14 |
10 | Correct | 2 ms | 256 KB | n=11 |
11 | Correct | 32 ms | 3192 KB | n=50000 |
12 | Correct | 26 ms | 3180 KB | n=50000 |
13 | Correct | 2 ms | 376 KB | n=10 |
14 | Correct | 2 ms | 376 KB | n=685 |
15 | Correct | 2 ms | 376 KB | n=623 |
16 | Correct | 3 ms | 376 KB | n=973 |
17 | Correct | 3 ms | 376 KB | n=989 |
18 | Correct | 2 ms | 312 KB | n=563 |
19 | Correct | 3 ms | 376 KB | n=592 |
20 | Correct | 3 ms | 376 KB | n=938 |
21 | Correct | 3 ms | 376 KB | n=747 |
22 | Correct | 3 ms | 376 KB | n=991 |
23 | Correct | 627 ms | 50236 KB | n=1000000 |
24 | Correct | 412 ms | 39204 KB | n=666666 |
25 | Correct | 230 ms | 21736 KB | n=400000 |
26 | Correct | 163 ms | 16516 KB | n=285714 |
27 | Correct | 12 ms | 1648 KB | n=20000 |
28 | Correct | 98 ms | 12124 KB | n=181818 |
29 | Correct | 7 ms | 1020 KB | n=10000 |
30 | Correct | 6 ms | 888 KB | n=6666 |
31 | Correct | 4 ms | 632 KB | n=4000 |
32 | Correct | 7 ms | 1048 KB | n=2857 |
33 | Correct | 4 ms | 504 KB | n=2000 |
34 | Correct | 23 ms | 1892 KB | n=23514 |
35 | Correct | 22 ms | 1904 KB | n=23514 |
36 | Correct | 3 ms | 376 KB | n=940 |
37 | Correct | 2 ms | 256 KB | n=2 |
38 | Correct | 72 ms | 5716 KB | n=100000 |
39 | Correct | 62 ms | 5860 KB | n=100000 |
40 | Correct | 2 ms | 380 KB | n=10 |
41 | Correct | 3 ms | 376 KB | n=100 |
42 | Correct | 5 ms | 632 KB | n=1000 |
43 | Correct | 793 ms | 63524 KB | n=1000000 |
44 | Correct | 1251 ms | 73260 KB | n=1000000 |
45 | Correct | 842 ms | 49860 KB | n=666666 |
46 | Correct | 486 ms | 28484 KB | n=400000 |
47 | Correct | 15 ms | 1300 KB | n=2336 |
48 | Correct | 754 ms | 44128 KB | n=285714 |
49 | Correct | 638 ms | 40124 KB | n=181818 |
50 | Correct | 41 ms | 3436 KB | n=40000 |
51 | Correct | 21 ms | 1904 KB | n=20000 |
52 | Correct | 12 ms | 1272 KB | n=10000 |
53 | Correct | 65 ms | 4968 KB | n=6666 |
54 | Correct | 8 ms | 888 KB | n=4000 |
55 | Correct | 274 ms | 17140 KB | n=2857 |
56 | Correct | 6 ms | 760 KB | n=2000 |