# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
89448 | 2018-12-14T17:12:21 Z | antimirage | Gift (IZhO18_nicegift) | C++17 | 2000 ms | 166220 KB |
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 1e6 + 7; const int INF = 1e9 + 7; int a[N], p[N]; int n, k, s; vector < pair < int, int > > dq[N]; vector < int > ans[N]; main(){ cin >> n >> k; int mx = -1; for (int i = 0; i < n; i++){ scanf("%lld", &a[i]); s += a[i]; mx = max(mx, a[i]); } int h = s / k, cs = 0, c = 0; if (mx > h || s % k != 0){ cout << -1; return 0; } for (int i = 0; i < n; i++){ if(a[i] == 0) continue; if (cs + a[i] >= h){ a[i] -= (h - cs); dq[c].push_back(make_pair(h - cs, i)); cs = 0; i--; c++; continue; } cs += a[i]; dq[c].push_back(make_pair(a[i], i)); } int g = 0; while (s != 0){ int mn = -1; for (int i = 0; i < k; i++){ if (mn == -1){ mn = dq[i][p[i]].first; continue; } mn = min(mn, dq[i][p[i]].first); } ans[g].push_back(mn); for (int i = 0; i < k; i++){ dq[i][p[i]].first -= mn; ans[g].push_back(dq[i][p[i]].second + 1); if(dq[i][p[i]].first == 0) p[i]++; } g++; s -= (mn * k); } cout << g << endl; int it = 0; while (it != g){ for (int i = 0; i < (int)ans[it].size(); i++){ cout << ans[it][i] << " "; } cout << endl; it++; } } /** 4 2 2 3 3 2 **/
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 51 ms | 47224 KB | n=4 |
2 | Correct | 47 ms | 47348 KB | n=3 |
3 | Correct | 48 ms | 47424 KB | n=3 |
4 | Correct | 47 ms | 47424 KB | n=4 |
5 | Correct | 50 ms | 47520 KB | n=4 |
6 | Correct | 49 ms | 47520 KB | n=2 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 51 ms | 47224 KB | n=4 |
2 | Correct | 47 ms | 47348 KB | n=3 |
3 | Correct | 48 ms | 47424 KB | n=3 |
4 | Correct | 47 ms | 47424 KB | n=4 |
5 | Correct | 50 ms | 47520 KB | n=4 |
6 | Correct | 49 ms | 47520 KB | n=2 |
7 | Correct | 49 ms | 47528 KB | n=5 |
8 | Correct | 47 ms | 47528 KB | n=8 |
9 | Correct | 48 ms | 47616 KB | n=14 |
10 | Correct | 48 ms | 47616 KB | n=11 |
11 | Correct | 145 ms | 51284 KB | n=50000 |
12 | Correct | 141 ms | 51284 KB | n=50000 |
13 | Correct | 47 ms | 51284 KB | n=10 |
14 | Correct | 43 ms | 51284 KB | n=685 |
15 | Correct | 53 ms | 51284 KB | n=623 |
16 | Correct | 44 ms | 51284 KB | n=973 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 51 ms | 47224 KB | n=4 |
2 | Correct | 47 ms | 47348 KB | n=3 |
3 | Correct | 48 ms | 47424 KB | n=3 |
4 | Correct | 47 ms | 47424 KB | n=4 |
5 | Correct | 50 ms | 47520 KB | n=4 |
6 | Correct | 49 ms | 47520 KB | n=2 |
7 | Correct | 49 ms | 47528 KB | n=5 |
8 | Correct | 47 ms | 47528 KB | n=8 |
9 | Correct | 48 ms | 47616 KB | n=14 |
10 | Correct | 48 ms | 47616 KB | n=11 |
11 | Correct | 145 ms | 51284 KB | n=50000 |
12 | Correct | 141 ms | 51284 KB | n=50000 |
13 | Correct | 47 ms | 51284 KB | n=10 |
14 | Correct | 43 ms | 51284 KB | n=685 |
15 | Correct | 53 ms | 51284 KB | n=623 |
16 | Correct | 44 ms | 51284 KB | n=973 |
17 | Correct | 44 ms | 51284 KB | n=989 |
18 | Correct | 43 ms | 51284 KB | n=563 |
19 | Correct | 53 ms | 51284 KB | n=592 |
20 | Correct | 45 ms | 51284 KB | n=938 |
21 | Correct | 44 ms | 51284 KB | n=747 |
22 | Correct | 45 ms | 51284 KB | n=991 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1296 ms | 108664 KB | n=1000000 |
2 | Correct | 680 ms | 108664 KB | n=666666 |
3 | Correct | 339 ms | 108664 KB | n=400000 |
4 | Correct | 923 ms | 112056 KB | n=285714 |
5 | Correct | 58 ms | 112056 KB | n=20000 |
6 | Correct | 694 ms | 113772 KB | n=181818 |
7 | Correct | 58 ms | 113772 KB | n=10000 |
8 | Correct | 95 ms | 113772 KB | n=6666 |
9 | Correct | 45 ms | 113772 KB | n=4000 |
10 | Correct | 293 ms | 113772 KB | n=2857 |
11 | Correct | 55 ms | 113772 KB | n=2000 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 51 ms | 47224 KB | n=4 |
2 | Correct | 47 ms | 47348 KB | n=3 |
3 | Correct | 48 ms | 47424 KB | n=3 |
4 | Correct | 47 ms | 47424 KB | n=4 |
5 | Correct | 50 ms | 47520 KB | n=4 |
6 | Correct | 49 ms | 47520 KB | n=2 |
7 | Correct | 49 ms | 47528 KB | n=5 |
8 | Correct | 47 ms | 47528 KB | n=8 |
9 | Correct | 48 ms | 47616 KB | n=14 |
10 | Correct | 48 ms | 47616 KB | n=11 |
11 | Correct | 145 ms | 51284 KB | n=50000 |
12 | Correct | 141 ms | 51284 KB | n=50000 |
13 | Correct | 47 ms | 51284 KB | n=10 |
14 | Correct | 43 ms | 51284 KB | n=685 |
15 | Correct | 53 ms | 51284 KB | n=623 |
16 | Correct | 44 ms | 51284 KB | n=973 |
17 | Correct | 44 ms | 51284 KB | n=989 |
18 | Correct | 43 ms | 51284 KB | n=563 |
19 | Correct | 53 ms | 51284 KB | n=592 |
20 | Correct | 45 ms | 51284 KB | n=938 |
21 | Correct | 44 ms | 51284 KB | n=747 |
22 | Correct | 45 ms | 51284 KB | n=991 |
23 | Correct | 1296 ms | 108664 KB | n=1000000 |
24 | Correct | 680 ms | 108664 KB | n=666666 |
25 | Correct | 339 ms | 108664 KB | n=400000 |
26 | Correct | 923 ms | 112056 KB | n=285714 |
27 | Correct | 58 ms | 112056 KB | n=20000 |
28 | Correct | 694 ms | 113772 KB | n=181818 |
29 | Correct | 58 ms | 113772 KB | n=10000 |
30 | Correct | 95 ms | 113772 KB | n=6666 |
31 | Correct | 45 ms | 113772 KB | n=4000 |
32 | Correct | 293 ms | 113772 KB | n=2857 |
33 | Correct | 55 ms | 113772 KB | n=2000 |
34 | Correct | 102 ms | 113772 KB | n=23514 |
35 | Correct | 109 ms | 113772 KB | n=23514 |
36 | Correct | 52 ms | 113772 KB | n=940 |
37 | Correct | 49 ms | 113772 KB | n=2 |
38 | Correct | 314 ms | 113772 KB | n=100000 |
39 | Correct | 314 ms | 113772 KB | n=100000 |
40 | Correct | 50 ms | 113772 KB | n=10 |
41 | Correct | 50 ms | 113772 KB | n=100 |
42 | Correct | 57 ms | 113772 KB | n=1000 |
43 | Execution timed out | 2056 ms | 166220 KB | Time limit exceeded |
44 | Halted | 0 ms | 0 KB | - |