# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
169772 | 2019-12-22T20:00:58 Z | super_j6 | Bootfall (IZhO17_bootfall) | C++14 | 1000 ms | 13204 KB |
#include <iostream> #include <cstdio> #include <algorithm> #include <set> #include <vector> using namespace std; #define endl '\n' #define pi pair<int, int> const int maxn = 500, m = 250001; int n; int a[maxn], dp[m]; set<int> cur; int s; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> n; dp[0] = 1; for(int i = 0; i < n; i++){ cin >> a[i]; s += a[i]; for(int j = m - a[i] - 1; j >= 0; j--){ dp[j + a[i]] += dp[j]; } } if(s % 2 || !dp[s / 2]){ cout << 0 << endl; cout << endl; return 0; } for(int i = 1; i < m; i++) cur.insert(i); for(int i = 0; i < n; i++){ for(int j = 0; j < m - a[i]; j++){ dp[j + a[i]] -= dp[j]; } for(auto it = cur.begin(); it != cur.end();){ int x = *it; it++; if((s - a[i] + x) % 2 || !dp[(s - a[i] + x) / 2]) cur.erase(x); } for(int j = m - a[i] - 1; j >= 0; j--){ dp[j + a[i]] += dp[j]; } } vector<int> ans; for(auto it = cur.begin(); it != cur.end(); it++) ans.push_back(*it); cout << ans.size() << endl; if(!ans.empty()){ cout << ans[0]; for(int i = 1; i < ans.size(); i++) cout << " " << ans[i]; } cout << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 103 ms | 13048 KB | Output is correct |
2 | Correct | 103 ms | 13052 KB | Output is correct |
3 | Correct | 4 ms | 1272 KB | Output is correct |
4 | Correct | 101 ms | 13048 KB | Output is correct |
5 | Correct | 119 ms | 13128 KB | Output is correct |
6 | Correct | 105 ms | 13032 KB | Output is correct |
7 | Correct | 104 ms | 13048 KB | Output is correct |
8 | Correct | 111 ms | 13052 KB | Output is correct |
9 | Correct | 110 ms | 13048 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 103 ms | 13048 KB | Output is correct |
2 | Correct | 103 ms | 13052 KB | Output is correct |
3 | Correct | 4 ms | 1272 KB | Output is correct |
4 | Correct | 101 ms | 13048 KB | Output is correct |
5 | Correct | 119 ms | 13128 KB | Output is correct |
6 | Correct | 105 ms | 13032 KB | Output is correct |
7 | Correct | 104 ms | 13048 KB | Output is correct |
8 | Correct | 111 ms | 13052 KB | Output is correct |
9 | Correct | 110 ms | 13048 KB | Output is correct |
10 | Correct | 115 ms | 13160 KB | Output is correct |
11 | Correct | 125 ms | 12996 KB | Output is correct |
12 | Correct | 117 ms | 13104 KB | Output is correct |
13 | Correct | 115 ms | 13048 KB | Output is correct |
14 | Correct | 120 ms | 13048 KB | Output is correct |
15 | Correct | 121 ms | 13048 KB | Output is correct |
16 | Correct | 121 ms | 13176 KB | Output is correct |
17 | Correct | 115 ms | 13144 KB | Output is correct |
18 | Correct | 117 ms | 13048 KB | Output is correct |
19 | Correct | 124 ms | 13048 KB | Output is correct |
20 | Correct | 117 ms | 13148 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 103 ms | 13048 KB | Output is correct |
2 | Correct | 103 ms | 13052 KB | Output is correct |
3 | Correct | 4 ms | 1272 KB | Output is correct |
4 | Correct | 101 ms | 13048 KB | Output is correct |
5 | Correct | 119 ms | 13128 KB | Output is correct |
6 | Correct | 105 ms | 13032 KB | Output is correct |
7 | Correct | 104 ms | 13048 KB | Output is correct |
8 | Correct | 111 ms | 13052 KB | Output is correct |
9 | Correct | 110 ms | 13048 KB | Output is correct |
10 | Correct | 115 ms | 13160 KB | Output is correct |
11 | Correct | 125 ms | 12996 KB | Output is correct |
12 | Correct | 117 ms | 13104 KB | Output is correct |
13 | Correct | 115 ms | 13048 KB | Output is correct |
14 | Correct | 120 ms | 13048 KB | Output is correct |
15 | Correct | 121 ms | 13048 KB | Output is correct |
16 | Correct | 121 ms | 13176 KB | Output is correct |
17 | Correct | 115 ms | 13144 KB | Output is correct |
18 | Correct | 117 ms | 13048 KB | Output is correct |
19 | Correct | 124 ms | 13048 KB | Output is correct |
20 | Correct | 117 ms | 13148 KB | Output is correct |
21 | Correct | 142 ms | 13016 KB | Output is correct |
22 | Correct | 146 ms | 13076 KB | Output is correct |
23 | Correct | 134 ms | 13048 KB | Output is correct |
24 | Correct | 159 ms | 13008 KB | Output is correct |
25 | Correct | 159 ms | 13136 KB | Output is correct |
26 | Correct | 169 ms | 13048 KB | Output is correct |
27 | Correct | 161 ms | 13048 KB | Output is correct |
28 | Correct | 161 ms | 13012 KB | Output is correct |
29 | Correct | 158 ms | 13136 KB | Output is correct |
30 | Correct | 154 ms | 13048 KB | Output is correct |
31 | Correct | 160 ms | 13048 KB | Output is correct |
32 | Correct | 163 ms | 13048 KB | Output is correct |
33 | Correct | 153 ms | 13048 KB | Output is correct |
34 | Correct | 153 ms | 13176 KB | Output is correct |
35 | Correct | 157 ms | 13068 KB | Output is correct |
36 | Correct | 165 ms | 13056 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 103 ms | 13048 KB | Output is correct |
2 | Correct | 103 ms | 13052 KB | Output is correct |
3 | Correct | 4 ms | 1272 KB | Output is correct |
4 | Correct | 101 ms | 13048 KB | Output is correct |
5 | Correct | 119 ms | 13128 KB | Output is correct |
6 | Correct | 105 ms | 13032 KB | Output is correct |
7 | Correct | 104 ms | 13048 KB | Output is correct |
8 | Correct | 111 ms | 13052 KB | Output is correct |
9 | Correct | 110 ms | 13048 KB | Output is correct |
10 | Correct | 115 ms | 13160 KB | Output is correct |
11 | Correct | 125 ms | 12996 KB | Output is correct |
12 | Correct | 117 ms | 13104 KB | Output is correct |
13 | Correct | 115 ms | 13048 KB | Output is correct |
14 | Correct | 120 ms | 13048 KB | Output is correct |
15 | Correct | 121 ms | 13048 KB | Output is correct |
16 | Correct | 121 ms | 13176 KB | Output is correct |
17 | Correct | 115 ms | 13144 KB | Output is correct |
18 | Correct | 117 ms | 13048 KB | Output is correct |
19 | Correct | 124 ms | 13048 KB | Output is correct |
20 | Correct | 117 ms | 13148 KB | Output is correct |
21 | Correct | 142 ms | 13016 KB | Output is correct |
22 | Correct | 146 ms | 13076 KB | Output is correct |
23 | Correct | 134 ms | 13048 KB | Output is correct |
24 | Correct | 159 ms | 13008 KB | Output is correct |
25 | Correct | 159 ms | 13136 KB | Output is correct |
26 | Correct | 169 ms | 13048 KB | Output is correct |
27 | Correct | 161 ms | 13048 KB | Output is correct |
28 | Correct | 161 ms | 13012 KB | Output is correct |
29 | Correct | 158 ms | 13136 KB | Output is correct |
30 | Correct | 154 ms | 13048 KB | Output is correct |
31 | Correct | 160 ms | 13048 KB | Output is correct |
32 | Correct | 163 ms | 13048 KB | Output is correct |
33 | Correct | 153 ms | 13048 KB | Output is correct |
34 | Correct | 153 ms | 13176 KB | Output is correct |
35 | Correct | 157 ms | 13068 KB | Output is correct |
36 | Correct | 165 ms | 13056 KB | Output is correct |
37 | Correct | 248 ms | 13116 KB | Output is correct |
38 | Correct | 235 ms | 13048 KB | Output is correct |
39 | Correct | 225 ms | 13048 KB | Output is correct |
40 | Correct | 305 ms | 13052 KB | Output is correct |
41 | Correct | 235 ms | 13116 KB | Output is correct |
42 | Correct | 282 ms | 13104 KB | Output is correct |
43 | Correct | 314 ms | 13080 KB | Output is correct |
44 | Correct | 326 ms | 13128 KB | Output is correct |
45 | Correct | 335 ms | 13052 KB | Output is correct |
46 | Correct | 243 ms | 13176 KB | Output is correct |
47 | Correct | 294 ms | 13048 KB | Output is correct |
48 | Correct | 316 ms | 13192 KB | Output is correct |
49 | Correct | 244 ms | 13048 KB | Output is correct |
50 | Correct | 302 ms | 13176 KB | Output is correct |
51 | Correct | 42 ms | 1272 KB | Output is correct |
52 | Correct | 355 ms | 13176 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 103 ms | 13048 KB | Output is correct |
2 | Correct | 103 ms | 13052 KB | Output is correct |
3 | Correct | 4 ms | 1272 KB | Output is correct |
4 | Correct | 101 ms | 13048 KB | Output is correct |
5 | Correct | 119 ms | 13128 KB | Output is correct |
6 | Correct | 105 ms | 13032 KB | Output is correct |
7 | Correct | 104 ms | 13048 KB | Output is correct |
8 | Correct | 111 ms | 13052 KB | Output is correct |
9 | Correct | 110 ms | 13048 KB | Output is correct |
10 | Correct | 115 ms | 13160 KB | Output is correct |
11 | Correct | 125 ms | 12996 KB | Output is correct |
12 | Correct | 117 ms | 13104 KB | Output is correct |
13 | Correct | 115 ms | 13048 KB | Output is correct |
14 | Correct | 120 ms | 13048 KB | Output is correct |
15 | Correct | 121 ms | 13048 KB | Output is correct |
16 | Correct | 121 ms | 13176 KB | Output is correct |
17 | Correct | 115 ms | 13144 KB | Output is correct |
18 | Correct | 117 ms | 13048 KB | Output is correct |
19 | Correct | 124 ms | 13048 KB | Output is correct |
20 | Correct | 117 ms | 13148 KB | Output is correct |
21 | Correct | 142 ms | 13016 KB | Output is correct |
22 | Correct | 146 ms | 13076 KB | Output is correct |
23 | Correct | 134 ms | 13048 KB | Output is correct |
24 | Correct | 159 ms | 13008 KB | Output is correct |
25 | Correct | 159 ms | 13136 KB | Output is correct |
26 | Correct | 169 ms | 13048 KB | Output is correct |
27 | Correct | 161 ms | 13048 KB | Output is correct |
28 | Correct | 161 ms | 13012 KB | Output is correct |
29 | Correct | 158 ms | 13136 KB | Output is correct |
30 | Correct | 154 ms | 13048 KB | Output is correct |
31 | Correct | 160 ms | 13048 KB | Output is correct |
32 | Correct | 163 ms | 13048 KB | Output is correct |
33 | Correct | 153 ms | 13048 KB | Output is correct |
34 | Correct | 153 ms | 13176 KB | Output is correct |
35 | Correct | 157 ms | 13068 KB | Output is correct |
36 | Correct | 165 ms | 13056 KB | Output is correct |
37 | Correct | 248 ms | 13116 KB | Output is correct |
38 | Correct | 235 ms | 13048 KB | Output is correct |
39 | Correct | 225 ms | 13048 KB | Output is correct |
40 | Correct | 305 ms | 13052 KB | Output is correct |
41 | Correct | 235 ms | 13116 KB | Output is correct |
42 | Correct | 282 ms | 13104 KB | Output is correct |
43 | Correct | 314 ms | 13080 KB | Output is correct |
44 | Correct | 326 ms | 13128 KB | Output is correct |
45 | Correct | 335 ms | 13052 KB | Output is correct |
46 | Correct | 243 ms | 13176 KB | Output is correct |
47 | Correct | 294 ms | 13048 KB | Output is correct |
48 | Correct | 316 ms | 13192 KB | Output is correct |
49 | Correct | 244 ms | 13048 KB | Output is correct |
50 | Correct | 302 ms | 13176 KB | Output is correct |
51 | Correct | 42 ms | 1272 KB | Output is correct |
52 | Correct | 355 ms | 13176 KB | Output is correct |
53 | Correct | 357 ms | 13204 KB | Output is correct |
54 | Correct | 421 ms | 13100 KB | Output is correct |
55 | Correct | 523 ms | 13048 KB | Output is correct |
56 | Correct | 378 ms | 13048 KB | Output is correct |
57 | Correct | 539 ms | 13056 KB | Output is correct |
58 | Correct | 425 ms | 13176 KB | Output is correct |
59 | Correct | 462 ms | 13176 KB | Output is correct |
60 | Correct | 58 ms | 1400 KB | Output is correct |
61 | Correct | 486 ms | 13048 KB | Output is correct |
62 | Correct | 486 ms | 13176 KB | Output is correct |
63 | Correct | 487 ms | 13048 KB | Output is correct |
64 | Correct | 465 ms | 13100 KB | Output is correct |
65 | Correct | 265 ms | 13188 KB | Output is correct |
66 | Correct | 294 ms | 13024 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 103 ms | 13048 KB | Output is correct |
2 | Correct | 103 ms | 13052 KB | Output is correct |
3 | Correct | 4 ms | 1272 KB | Output is correct |
4 | Correct | 101 ms | 13048 KB | Output is correct |
5 | Correct | 119 ms | 13128 KB | Output is correct |
6 | Correct | 105 ms | 13032 KB | Output is correct |
7 | Correct | 104 ms | 13048 KB | Output is correct |
8 | Correct | 111 ms | 13052 KB | Output is correct |
9 | Correct | 110 ms | 13048 KB | Output is correct |
10 | Correct | 115 ms | 13160 KB | Output is correct |
11 | Correct | 125 ms | 12996 KB | Output is correct |
12 | Correct | 117 ms | 13104 KB | Output is correct |
13 | Correct | 115 ms | 13048 KB | Output is correct |
14 | Correct | 120 ms | 13048 KB | Output is correct |
15 | Correct | 121 ms | 13048 KB | Output is correct |
16 | Correct | 121 ms | 13176 KB | Output is correct |
17 | Correct | 115 ms | 13144 KB | Output is correct |
18 | Correct | 117 ms | 13048 KB | Output is correct |
19 | Correct | 124 ms | 13048 KB | Output is correct |
20 | Correct | 117 ms | 13148 KB | Output is correct |
21 | Correct | 142 ms | 13016 KB | Output is correct |
22 | Correct | 146 ms | 13076 KB | Output is correct |
23 | Correct | 134 ms | 13048 KB | Output is correct |
24 | Correct | 159 ms | 13008 KB | Output is correct |
25 | Correct | 159 ms | 13136 KB | Output is correct |
26 | Correct | 169 ms | 13048 KB | Output is correct |
27 | Correct | 161 ms | 13048 KB | Output is correct |
28 | Correct | 161 ms | 13012 KB | Output is correct |
29 | Correct | 158 ms | 13136 KB | Output is correct |
30 | Correct | 154 ms | 13048 KB | Output is correct |
31 | Correct | 160 ms | 13048 KB | Output is correct |
32 | Correct | 163 ms | 13048 KB | Output is correct |
33 | Correct | 153 ms | 13048 KB | Output is correct |
34 | Correct | 153 ms | 13176 KB | Output is correct |
35 | Correct | 157 ms | 13068 KB | Output is correct |
36 | Correct | 165 ms | 13056 KB | Output is correct |
37 | Correct | 248 ms | 13116 KB | Output is correct |
38 | Correct | 235 ms | 13048 KB | Output is correct |
39 | Correct | 225 ms | 13048 KB | Output is correct |
40 | Correct | 305 ms | 13052 KB | Output is correct |
41 | Correct | 235 ms | 13116 KB | Output is correct |
42 | Correct | 282 ms | 13104 KB | Output is correct |
43 | Correct | 314 ms | 13080 KB | Output is correct |
44 | Correct | 326 ms | 13128 KB | Output is correct |
45 | Correct | 335 ms | 13052 KB | Output is correct |
46 | Correct | 243 ms | 13176 KB | Output is correct |
47 | Correct | 294 ms | 13048 KB | Output is correct |
48 | Correct | 316 ms | 13192 KB | Output is correct |
49 | Correct | 244 ms | 13048 KB | Output is correct |
50 | Correct | 302 ms | 13176 KB | Output is correct |
51 | Correct | 42 ms | 1272 KB | Output is correct |
52 | Correct | 355 ms | 13176 KB | Output is correct |
53 | Correct | 357 ms | 13204 KB | Output is correct |
54 | Correct | 421 ms | 13100 KB | Output is correct |
55 | Correct | 523 ms | 13048 KB | Output is correct |
56 | Correct | 378 ms | 13048 KB | Output is correct |
57 | Correct | 539 ms | 13056 KB | Output is correct |
58 | Correct | 425 ms | 13176 KB | Output is correct |
59 | Correct | 462 ms | 13176 KB | Output is correct |
60 | Correct | 58 ms | 1400 KB | Output is correct |
61 | Correct | 486 ms | 13048 KB | Output is correct |
62 | Correct | 486 ms | 13176 KB | Output is correct |
63 | Correct | 487 ms | 13048 KB | Output is correct |
64 | Correct | 465 ms | 13100 KB | Output is correct |
65 | Correct | 265 ms | 13188 KB | Output is correct |
66 | Correct | 294 ms | 13024 KB | Output is correct |
67 | Correct | 525 ms | 13140 KB | Output is correct |
68 | Correct | 81 ms | 1272 KB | Output is correct |
69 | Execution timed out | 1086 ms | 13048 KB | Time limit exceeded |
70 | Halted | 0 ms | 0 KB | - |