# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
335546 | 2020-12-13T03:46:01 Z | luciocf | Bootfall (IZhO17_bootfall) | C++14 | 272 ms | 17260 KB |
#include <bits/stdc++.h> using namespace std; const int maxn = 510; const int maxs = 250010; int a[maxn]; int s; bitset<maxs> aux, bs[maxn]; void solve(int l, int r) { if (l > r) return; int mid = (l+r)>>1; bitset<maxs> ant = aux; for (int i = l; i <= mid; i++) aux |= (aux<<a[i]); solve(mid+1, r); aux = ant; for (int i = r; i >= mid; i--) aux |= (aux<<a[i]); solve(l, mid-1); aux = ant; s -= a[mid]; for (int i = l; i < mid; i++) aux |= (aux<<a[i]); for (int i = r; i > mid; i--) aux |= (aux<<a[i]); for (int i = (s+1)/2; i < maxs; i++) if (aux[i]) bs[mid][2*i-s] = 1; aux = ant; s += a[mid]; } int main(void) { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); s += a[i]; } aux[0] = 1; for (int i = 1; i <= n; i++) aux |= (aux<<a[i]); if (s&1 || !aux[s/2]) { printf("0\n"); return 0; } aux.reset(); aux[0] = 1; solve(1, n); bitset<maxs> ans; for (int i = 1; i < maxs; i++) ans[i] = 1; for (int i = 1; i <= n; i++) ans &= bs[i]; int tot = 0; for (int i = 1; i < maxs; i++) if (ans[i]) ++tot; printf("%d\n", tot); for (int i = 1; i < maxs; i++) if (ans[i]) printf("%d ", i); printf("\n"); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 876 KB | Output is correct |
2 | Correct | 4 ms | 748 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 3 ms | 748 KB | Output is correct |
5 | Correct | 9 ms | 876 KB | Output is correct |
6 | Correct | 5 ms | 876 KB | Output is correct |
7 | Correct | 5 ms | 748 KB | Output is correct |
8 | Correct | 8 ms | 876 KB | Output is correct |
9 | Correct | 7 ms | 1004 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 876 KB | Output is correct |
2 | Correct | 4 ms | 748 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 3 ms | 748 KB | Output is correct |
5 | Correct | 9 ms | 876 KB | Output is correct |
6 | Correct | 5 ms | 876 KB | Output is correct |
7 | Correct | 5 ms | 748 KB | Output is correct |
8 | Correct | 8 ms | 876 KB | Output is correct |
9 | Correct | 7 ms | 1004 KB | Output is correct |
10 | Correct | 16 ms | 1004 KB | Output is correct |
11 | Correct | 16 ms | 1004 KB | Output is correct |
12 | Correct | 17 ms | 1004 KB | Output is correct |
13 | Correct | 14 ms | 1004 KB | Output is correct |
14 | Correct | 15 ms | 1004 KB | Output is correct |
15 | Correct | 19 ms | 1004 KB | Output is correct |
16 | Correct | 16 ms | 1004 KB | Output is correct |
17 | Correct | 10 ms | 1004 KB | Output is correct |
18 | Correct | 17 ms | 1004 KB | Output is correct |
19 | Correct | 16 ms | 1132 KB | Output is correct |
20 | Correct | 17 ms | 1004 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 876 KB | Output is correct |
2 | Correct | 4 ms | 748 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 3 ms | 748 KB | Output is correct |
5 | Correct | 9 ms | 876 KB | Output is correct |
6 | Correct | 5 ms | 876 KB | Output is correct |
7 | Correct | 5 ms | 748 KB | Output is correct |
8 | Correct | 8 ms | 876 KB | Output is correct |
9 | Correct | 7 ms | 1004 KB | Output is correct |
10 | Correct | 16 ms | 1004 KB | Output is correct |
11 | Correct | 16 ms | 1004 KB | Output is correct |
12 | Correct | 17 ms | 1004 KB | Output is correct |
13 | Correct | 14 ms | 1004 KB | Output is correct |
14 | Correct | 15 ms | 1004 KB | Output is correct |
15 | Correct | 19 ms | 1004 KB | Output is correct |
16 | Correct | 16 ms | 1004 KB | Output is correct |
17 | Correct | 10 ms | 1004 KB | Output is correct |
18 | Correct | 17 ms | 1004 KB | Output is correct |
19 | Correct | 16 ms | 1132 KB | Output is correct |
20 | Correct | 17 ms | 1004 KB | Output is correct |
21 | Correct | 34 ms | 1388 KB | Output is correct |
22 | Correct | 39 ms | 1516 KB | Output is correct |
23 | Correct | 26 ms | 1132 KB | Output is correct |
24 | Correct | 55 ms | 1664 KB | Output is correct |
25 | Correct | 54 ms | 1516 KB | Output is correct |
26 | Correct | 52 ms | 1536 KB | Output is correct |
27 | Correct | 52 ms | 1516 KB | Output is correct |
28 | Correct | 52 ms | 1516 KB | Output is correct |
29 | Correct | 59 ms | 1644 KB | Output is correct |
30 | Correct | 53 ms | 1644 KB | Output is correct |
31 | Correct | 53 ms | 1516 KB | Output is correct |
32 | Correct | 53 ms | 1516 KB | Output is correct |
33 | Correct | 52 ms | 1644 KB | Output is correct |
34 | Correct | 60 ms | 1644 KB | Output is correct |
35 | Correct | 52 ms | 1600 KB | Output is correct |
36 | Correct | 54 ms | 1540 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 876 KB | Output is correct |
2 | Correct | 4 ms | 748 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 3 ms | 748 KB | Output is correct |
5 | Correct | 9 ms | 876 KB | Output is correct |
6 | Correct | 5 ms | 876 KB | Output is correct |
7 | Correct | 5 ms | 748 KB | Output is correct |
8 | Correct | 8 ms | 876 KB | Output is correct |
9 | Correct | 7 ms | 1004 KB | Output is correct |
10 | Correct | 16 ms | 1004 KB | Output is correct |
11 | Correct | 16 ms | 1004 KB | Output is correct |
12 | Correct | 17 ms | 1004 KB | Output is correct |
13 | Correct | 14 ms | 1004 KB | Output is correct |
14 | Correct | 15 ms | 1004 KB | Output is correct |
15 | Correct | 19 ms | 1004 KB | Output is correct |
16 | Correct | 16 ms | 1004 KB | Output is correct |
17 | Correct | 10 ms | 1004 KB | Output is correct |
18 | Correct | 17 ms | 1004 KB | Output is correct |
19 | Correct | 16 ms | 1132 KB | Output is correct |
20 | Correct | 17 ms | 1004 KB | Output is correct |
21 | Correct | 34 ms | 1388 KB | Output is correct |
22 | Correct | 39 ms | 1516 KB | Output is correct |
23 | Correct | 26 ms | 1132 KB | Output is correct |
24 | Correct | 55 ms | 1664 KB | Output is correct |
25 | Correct | 54 ms | 1516 KB | Output is correct |
26 | Correct | 52 ms | 1536 KB | Output is correct |
27 | Correct | 52 ms | 1516 KB | Output is correct |
28 | Correct | 52 ms | 1516 KB | Output is correct |
29 | Correct | 59 ms | 1644 KB | Output is correct |
30 | Correct | 53 ms | 1644 KB | Output is correct |
31 | Correct | 53 ms | 1516 KB | Output is correct |
32 | Correct | 53 ms | 1516 KB | Output is correct |
33 | Correct | 52 ms | 1644 KB | Output is correct |
34 | Correct | 60 ms | 1644 KB | Output is correct |
35 | Correct | 52 ms | 1600 KB | Output is correct |
36 | Correct | 54 ms | 1540 KB | Output is correct |
37 | Correct | 116 ms | 2540 KB | Output is correct |
38 | Correct | 109 ms | 2540 KB | Output is correct |
39 | Correct | 124 ms | 4076 KB | Output is correct |
40 | Correct | 149 ms | 3436 KB | Output is correct |
41 | Correct | 131 ms | 4784 KB | Output is correct |
42 | Correct | 134 ms | 3180 KB | Output is correct |
43 | Correct | 157 ms | 3948 KB | Output is correct |
44 | Correct | 133 ms | 4120 KB | Output is correct |
45 | Correct | 135 ms | 4116 KB | Output is correct |
46 | Correct | 141 ms | 3308 KB | Output is correct |
47 | Correct | 139 ms | 3180 KB | Output is correct |
48 | Correct | 133 ms | 4076 KB | Output is correct |
49 | Correct | 130 ms | 4076 KB | Output is correct |
50 | Correct | 138 ms | 3308 KB | Output is correct |
51 | Correct | 3 ms | 364 KB | Output is correct |
52 | Correct | 144 ms | 4800 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 876 KB | Output is correct |
2 | Correct | 4 ms | 748 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 3 ms | 748 KB | Output is correct |
5 | Correct | 9 ms | 876 KB | Output is correct |
6 | Correct | 5 ms | 876 KB | Output is correct |
7 | Correct | 5 ms | 748 KB | Output is correct |
8 | Correct | 8 ms | 876 KB | Output is correct |
9 | Correct | 7 ms | 1004 KB | Output is correct |
10 | Correct | 16 ms | 1004 KB | Output is correct |
11 | Correct | 16 ms | 1004 KB | Output is correct |
12 | Correct | 17 ms | 1004 KB | Output is correct |
13 | Correct | 14 ms | 1004 KB | Output is correct |
14 | Correct | 15 ms | 1004 KB | Output is correct |
15 | Correct | 19 ms | 1004 KB | Output is correct |
16 | Correct | 16 ms | 1004 KB | Output is correct |
17 | Correct | 10 ms | 1004 KB | Output is correct |
18 | Correct | 17 ms | 1004 KB | Output is correct |
19 | Correct | 16 ms | 1132 KB | Output is correct |
20 | Correct | 17 ms | 1004 KB | Output is correct |
21 | Correct | 34 ms | 1388 KB | Output is correct |
22 | Correct | 39 ms | 1516 KB | Output is correct |
23 | Correct | 26 ms | 1132 KB | Output is correct |
24 | Correct | 55 ms | 1664 KB | Output is correct |
25 | Correct | 54 ms | 1516 KB | Output is correct |
26 | Correct | 52 ms | 1536 KB | Output is correct |
27 | Correct | 52 ms | 1516 KB | Output is correct |
28 | Correct | 52 ms | 1516 KB | Output is correct |
29 | Correct | 59 ms | 1644 KB | Output is correct |
30 | Correct | 53 ms | 1644 KB | Output is correct |
31 | Correct | 53 ms | 1516 KB | Output is correct |
32 | Correct | 53 ms | 1516 KB | Output is correct |
33 | Correct | 52 ms | 1644 KB | Output is correct |
34 | Correct | 60 ms | 1644 KB | Output is correct |
35 | Correct | 52 ms | 1600 KB | Output is correct |
36 | Correct | 54 ms | 1540 KB | Output is correct |
37 | Correct | 116 ms | 2540 KB | Output is correct |
38 | Correct | 109 ms | 2540 KB | Output is correct |
39 | Correct | 124 ms | 4076 KB | Output is correct |
40 | Correct | 149 ms | 3436 KB | Output is correct |
41 | Correct | 131 ms | 4784 KB | Output is correct |
42 | Correct | 134 ms | 3180 KB | Output is correct |
43 | Correct | 157 ms | 3948 KB | Output is correct |
44 | Correct | 133 ms | 4120 KB | Output is correct |
45 | Correct | 135 ms | 4116 KB | Output is correct |
46 | Correct | 141 ms | 3308 KB | Output is correct |
47 | Correct | 139 ms | 3180 KB | Output is correct |
48 | Correct | 133 ms | 4076 KB | Output is correct |
49 | Correct | 130 ms | 4076 KB | Output is correct |
50 | Correct | 138 ms | 3308 KB | Output is correct |
51 | Correct | 3 ms | 364 KB | Output is correct |
52 | Correct | 144 ms | 4800 KB | Output is correct |
53 | Correct | 168 ms | 4292 KB | Output is correct |
54 | Correct | 192 ms | 5228 KB | Output is correct |
55 | Correct | 189 ms | 7704 KB | Output is correct |
56 | Correct | 167 ms | 4716 KB | Output is correct |
57 | Correct | 235 ms | 7956 KB | Output is correct |
58 | Correct | 193 ms | 5484 KB | Output is correct |
59 | Correct | 195 ms | 6252 KB | Output is correct |
60 | Correct | 4 ms | 364 KB | Output is correct |
61 | Correct | 189 ms | 6508 KB | Output is correct |
62 | Correct | 173 ms | 6508 KB | Output is correct |
63 | Correct | 173 ms | 6892 KB | Output is correct |
64 | Correct | 172 ms | 6764 KB | Output is correct |
65 | Correct | 165 ms | 4332 KB | Output is correct |
66 | Correct | 158 ms | 4588 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 876 KB | Output is correct |
2 | Correct | 4 ms | 748 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 3 ms | 748 KB | Output is correct |
5 | Correct | 9 ms | 876 KB | Output is correct |
6 | Correct | 5 ms | 876 KB | Output is correct |
7 | Correct | 5 ms | 748 KB | Output is correct |
8 | Correct | 8 ms | 876 KB | Output is correct |
9 | Correct | 7 ms | 1004 KB | Output is correct |
10 | Correct | 16 ms | 1004 KB | Output is correct |
11 | Correct | 16 ms | 1004 KB | Output is correct |
12 | Correct | 17 ms | 1004 KB | Output is correct |
13 | Correct | 14 ms | 1004 KB | Output is correct |
14 | Correct | 15 ms | 1004 KB | Output is correct |
15 | Correct | 19 ms | 1004 KB | Output is correct |
16 | Correct | 16 ms | 1004 KB | Output is correct |
17 | Correct | 10 ms | 1004 KB | Output is correct |
18 | Correct | 17 ms | 1004 KB | Output is correct |
19 | Correct | 16 ms | 1132 KB | Output is correct |
20 | Correct | 17 ms | 1004 KB | Output is correct |
21 | Correct | 34 ms | 1388 KB | Output is correct |
22 | Correct | 39 ms | 1516 KB | Output is correct |
23 | Correct | 26 ms | 1132 KB | Output is correct |
24 | Correct | 55 ms | 1664 KB | Output is correct |
25 | Correct | 54 ms | 1516 KB | Output is correct |
26 | Correct | 52 ms | 1536 KB | Output is correct |
27 | Correct | 52 ms | 1516 KB | Output is correct |
28 | Correct | 52 ms | 1516 KB | Output is correct |
29 | Correct | 59 ms | 1644 KB | Output is correct |
30 | Correct | 53 ms | 1644 KB | Output is correct |
31 | Correct | 53 ms | 1516 KB | Output is correct |
32 | Correct | 53 ms | 1516 KB | Output is correct |
33 | Correct | 52 ms | 1644 KB | Output is correct |
34 | Correct | 60 ms | 1644 KB | Output is correct |
35 | Correct | 52 ms | 1600 KB | Output is correct |
36 | Correct | 54 ms | 1540 KB | Output is correct |
37 | Correct | 116 ms | 2540 KB | Output is correct |
38 | Correct | 109 ms | 2540 KB | Output is correct |
39 | Correct | 124 ms | 4076 KB | Output is correct |
40 | Correct | 149 ms | 3436 KB | Output is correct |
41 | Correct | 131 ms | 4784 KB | Output is correct |
42 | Correct | 134 ms | 3180 KB | Output is correct |
43 | Correct | 157 ms | 3948 KB | Output is correct |
44 | Correct | 133 ms | 4120 KB | Output is correct |
45 | Correct | 135 ms | 4116 KB | Output is correct |
46 | Correct | 141 ms | 3308 KB | Output is correct |
47 | Correct | 139 ms | 3180 KB | Output is correct |
48 | Correct | 133 ms | 4076 KB | Output is correct |
49 | Correct | 130 ms | 4076 KB | Output is correct |
50 | Correct | 138 ms | 3308 KB | Output is correct |
51 | Correct | 3 ms | 364 KB | Output is correct |
52 | Correct | 144 ms | 4800 KB | Output is correct |
53 | Correct | 168 ms | 4292 KB | Output is correct |
54 | Correct | 192 ms | 5228 KB | Output is correct |
55 | Correct | 189 ms | 7704 KB | Output is correct |
56 | Correct | 167 ms | 4716 KB | Output is correct |
57 | Correct | 235 ms | 7956 KB | Output is correct |
58 | Correct | 193 ms | 5484 KB | Output is correct |
59 | Correct | 195 ms | 6252 KB | Output is correct |
60 | Correct | 4 ms | 364 KB | Output is correct |
61 | Correct | 189 ms | 6508 KB | Output is correct |
62 | Correct | 173 ms | 6508 KB | Output is correct |
63 | Correct | 173 ms | 6892 KB | Output is correct |
64 | Correct | 172 ms | 6764 KB | Output is correct |
65 | Correct | 165 ms | 4332 KB | Output is correct |
66 | Correct | 158 ms | 4588 KB | Output is correct |
67 | Correct | 218 ms | 7020 KB | Output is correct |
68 | Correct | 6 ms | 364 KB | Output is correct |
69 | Correct | 265 ms | 16780 KB | Output is correct |
70 | Correct | 272 ms | 11500 KB | Output is correct |
71 | Correct | 272 ms | 11244 KB | Output is correct |
72 | Correct | 268 ms | 10860 KB | Output is correct |
73 | Correct | 266 ms | 10860 KB | Output is correct |
74 | Correct | 269 ms | 17132 KB | Output is correct |
75 | Correct | 268 ms | 14444 KB | Output is correct |
76 | Correct | 257 ms | 17260 KB | Output is correct |
77 | Correct | 266 ms | 17260 KB | Output is correct |