# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
229887 | 2020-05-07T03:29:59 Z | pedroslrey | Bootfall (IZhO17_bootfall) | C++14 | 794 ms | 3244 KB |
#pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; using lli = long long int; #define debug(args...) fprintf(stderr, args) #define pb push_back #define fi first #define se second #define all(xs) xs.begin(), xs.end() const int INF = 1e9; int dp[510*510]; int xs[510]; int marc[510*510]; inline void add(int i, int s) { for (int k = s; k >= 0; --k) { lli tmp = 1LL*dp[k + xs[i]] + dp[k]; dp[k + xs[i]] = tmp%INF; } } inline void sub(int i, int s) { for (int k = 0; k <= s; ++k) { lli tmp = 1LL*dp[k + xs[i]] - dp[k]; dp[k + xs[i]] = tmp%INF; } } void init_dp(int n, int s) { dp[0] = 1; for (int i = 1; i <= n; ++i) add(i, s); } void solve(int n) { int s = 0; for (int i = 1; i <= n; ++i) s += xs[i]; init_dp(n, s); if (dp[s/2] == 0 || s%2 == 1) { printf("0\n"); return; } for (int i = 1; i <= n; ++i) { sub(i, s); for (int k = 1; k <= s; ++k) { if ((s - xs[i] + k)%2 == 1) marc[k] = 0; if (dp[(s - xs[i] - k)/2]) ++marc[k]; } add(i, s); } vector<int> ans; for (int k = 1; k <= s; ++k) if (marc[k] == n) ans.pb(k); printf("%d\n", (int) ans.size()); for (int a: ans) printf("%d ", a); printf("\n"); } int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", &xs[i]); solve(n); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 256 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 256 KB | Output is correct |
8 | Correct | 5 ms | 308 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 256 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 256 KB | Output is correct |
8 | Correct | 5 ms | 308 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 4 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 256 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 256 KB | Output is correct |
8 | Correct | 5 ms | 308 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 4 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 384 KB | Output is correct |
21 | Correct | 6 ms | 384 KB | Output is correct |
22 | Correct | 6 ms | 384 KB | Output is correct |
23 | Correct | 6 ms | 384 KB | Output is correct |
24 | Correct | 8 ms | 384 KB | Output is correct |
25 | Correct | 11 ms | 384 KB | Output is correct |
26 | Correct | 12 ms | 512 KB | Output is correct |
27 | Correct | 14 ms | 384 KB | Output is correct |
28 | Correct | 12 ms | 512 KB | Output is correct |
29 | Correct | 12 ms | 384 KB | Output is correct |
30 | Correct | 9 ms | 384 KB | Output is correct |
31 | Correct | 12 ms | 512 KB | Output is correct |
32 | Correct | 8 ms | 384 KB | Output is correct |
33 | Correct | 12 ms | 384 KB | Output is correct |
34 | Correct | 14 ms | 384 KB | Output is correct |
35 | Correct | 12 ms | 384 KB | Output is correct |
36 | Correct | 8 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 256 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 256 KB | Output is correct |
8 | Correct | 5 ms | 308 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 4 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 384 KB | Output is correct |
21 | Correct | 6 ms | 384 KB | Output is correct |
22 | Correct | 6 ms | 384 KB | Output is correct |
23 | Correct | 6 ms | 384 KB | Output is correct |
24 | Correct | 8 ms | 384 KB | Output is correct |
25 | Correct | 11 ms | 384 KB | Output is correct |
26 | Correct | 12 ms | 512 KB | Output is correct |
27 | Correct | 14 ms | 384 KB | Output is correct |
28 | Correct | 12 ms | 512 KB | Output is correct |
29 | Correct | 12 ms | 384 KB | Output is correct |
30 | Correct | 9 ms | 384 KB | Output is correct |
31 | Correct | 12 ms | 512 KB | Output is correct |
32 | Correct | 8 ms | 384 KB | Output is correct |
33 | Correct | 12 ms | 384 KB | Output is correct |
34 | Correct | 14 ms | 384 KB | Output is correct |
35 | Correct | 12 ms | 384 KB | Output is correct |
36 | Correct | 8 ms | 384 KB | Output is correct |
37 | Correct | 34 ms | 632 KB | Output is correct |
38 | Correct | 35 ms | 640 KB | Output is correct |
39 | Correct | 122 ms | 1016 KB | Output is correct |
40 | Correct | 72 ms | 760 KB | Output is correct |
41 | Correct | 147 ms | 944 KB | Output is correct |
42 | Correct | 60 ms | 760 KB | Output is correct |
43 | Correct | 106 ms | 1272 KB | Output is correct |
44 | Correct | 108 ms | 1144 KB | Output is correct |
45 | Correct | 109 ms | 1120 KB | Output is correct |
46 | Correct | 67 ms | 624 KB | Output is correct |
47 | Correct | 66 ms | 760 KB | Output is correct |
48 | Correct | 119 ms | 1128 KB | Output is correct |
49 | Correct | 120 ms | 888 KB | Output is correct |
50 | Correct | 67 ms | 760 KB | Output is correct |
51 | Correct | 19 ms | 384 KB | Output is correct |
52 | Correct | 149 ms | 1272 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 256 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 256 KB | Output is correct |
8 | Correct | 5 ms | 308 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 4 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 384 KB | Output is correct |
21 | Correct | 6 ms | 384 KB | Output is correct |
22 | Correct | 6 ms | 384 KB | Output is correct |
23 | Correct | 6 ms | 384 KB | Output is correct |
24 | Correct | 8 ms | 384 KB | Output is correct |
25 | Correct | 11 ms | 384 KB | Output is correct |
26 | Correct | 12 ms | 512 KB | Output is correct |
27 | Correct | 14 ms | 384 KB | Output is correct |
28 | Correct | 12 ms | 512 KB | Output is correct |
29 | Correct | 12 ms | 384 KB | Output is correct |
30 | Correct | 9 ms | 384 KB | Output is correct |
31 | Correct | 12 ms | 512 KB | Output is correct |
32 | Correct | 8 ms | 384 KB | Output is correct |
33 | Correct | 12 ms | 384 KB | Output is correct |
34 | Correct | 14 ms | 384 KB | Output is correct |
35 | Correct | 12 ms | 384 KB | Output is correct |
36 | Correct | 8 ms | 384 KB | Output is correct |
37 | Correct | 34 ms | 632 KB | Output is correct |
38 | Correct | 35 ms | 640 KB | Output is correct |
39 | Correct | 122 ms | 1016 KB | Output is correct |
40 | Correct | 72 ms | 760 KB | Output is correct |
41 | Correct | 147 ms | 944 KB | Output is correct |
42 | Correct | 60 ms | 760 KB | Output is correct |
43 | Correct | 106 ms | 1272 KB | Output is correct |
44 | Correct | 108 ms | 1144 KB | Output is correct |
45 | Correct | 109 ms | 1120 KB | Output is correct |
46 | Correct | 67 ms | 624 KB | Output is correct |
47 | Correct | 66 ms | 760 KB | Output is correct |
48 | Correct | 119 ms | 1128 KB | Output is correct |
49 | Correct | 120 ms | 888 KB | Output is correct |
50 | Correct | 67 ms | 760 KB | Output is correct |
51 | Correct | 19 ms | 384 KB | Output is correct |
52 | Correct | 149 ms | 1272 KB | Output is correct |
53 | Correct | 109 ms | 1016 KB | Output is correct |
54 | Correct | 150 ms | 1148 KB | Output is correct |
55 | Correct | 295 ms | 1880 KB | Output is correct |
56 | Correct | 135 ms | 1272 KB | Output is correct |
57 | Correct | 315 ms | 1908 KB | Output is correct |
58 | Correct | 168 ms | 1272 KB | Output is correct |
59 | Correct | 207 ms | 1652 KB | Output is correct |
60 | Correct | 44 ms | 632 KB | Output is correct |
61 | Correct | 232 ms | 1524 KB | Output is correct |
62 | Correct | 243 ms | 1644 KB | Output is correct |
63 | Correct | 260 ms | 1908 KB | Output is correct |
64 | Correct | 240 ms | 1780 KB | Output is correct |
65 | Correct | 118 ms | 760 KB | Output is correct |
66 | Correct | 129 ms | 888 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 256 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 256 KB | Output is correct |
8 | Correct | 5 ms | 308 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 4 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 384 KB | Output is correct |
21 | Correct | 6 ms | 384 KB | Output is correct |
22 | Correct | 6 ms | 384 KB | Output is correct |
23 | Correct | 6 ms | 384 KB | Output is correct |
24 | Correct | 8 ms | 384 KB | Output is correct |
25 | Correct | 11 ms | 384 KB | Output is correct |
26 | Correct | 12 ms | 512 KB | Output is correct |
27 | Correct | 14 ms | 384 KB | Output is correct |
28 | Correct | 12 ms | 512 KB | Output is correct |
29 | Correct | 12 ms | 384 KB | Output is correct |
30 | Correct | 9 ms | 384 KB | Output is correct |
31 | Correct | 12 ms | 512 KB | Output is correct |
32 | Correct | 8 ms | 384 KB | Output is correct |
33 | Correct | 12 ms | 384 KB | Output is correct |
34 | Correct | 14 ms | 384 KB | Output is correct |
35 | Correct | 12 ms | 384 KB | Output is correct |
36 | Correct | 8 ms | 384 KB | Output is correct |
37 | Correct | 34 ms | 632 KB | Output is correct |
38 | Correct | 35 ms | 640 KB | Output is correct |
39 | Correct | 122 ms | 1016 KB | Output is correct |
40 | Correct | 72 ms | 760 KB | Output is correct |
41 | Correct | 147 ms | 944 KB | Output is correct |
42 | Correct | 60 ms | 760 KB | Output is correct |
43 | Correct | 106 ms | 1272 KB | Output is correct |
44 | Correct | 108 ms | 1144 KB | Output is correct |
45 | Correct | 109 ms | 1120 KB | Output is correct |
46 | Correct | 67 ms | 624 KB | Output is correct |
47 | Correct | 66 ms | 760 KB | Output is correct |
48 | Correct | 119 ms | 1128 KB | Output is correct |
49 | Correct | 120 ms | 888 KB | Output is correct |
50 | Correct | 67 ms | 760 KB | Output is correct |
51 | Correct | 19 ms | 384 KB | Output is correct |
52 | Correct | 149 ms | 1272 KB | Output is correct |
53 | Correct | 109 ms | 1016 KB | Output is correct |
54 | Correct | 150 ms | 1148 KB | Output is correct |
55 | Correct | 295 ms | 1880 KB | Output is correct |
56 | Correct | 135 ms | 1272 KB | Output is correct |
57 | Correct | 315 ms | 1908 KB | Output is correct |
58 | Correct | 168 ms | 1272 KB | Output is correct |
59 | Correct | 207 ms | 1652 KB | Output is correct |
60 | Correct | 44 ms | 632 KB | Output is correct |
61 | Correct | 232 ms | 1524 KB | Output is correct |
62 | Correct | 243 ms | 1644 KB | Output is correct |
63 | Correct | 260 ms | 1908 KB | Output is correct |
64 | Correct | 240 ms | 1780 KB | Output is correct |
65 | Correct | 118 ms | 760 KB | Output is correct |
66 | Correct | 129 ms | 888 KB | Output is correct |
67 | Correct | 248 ms | 1524 KB | Output is correct |
68 | Correct | 121 ms | 888 KB | Output is correct |
69 | Incorrect | 794 ms | 3244 KB | Output isn't correct |
70 | Halted | 0 ms | 0 KB | - |