# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
169773 | 2019-12-22T20:05:11 Z | super_j6 | Bootfall (IZhO17_bootfall) | C++14 | 738 ms | 7992 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 / 2; 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 | 48 ms | 7160 KB | Output is correct |
2 | Correct | 49 ms | 7160 KB | Output is correct |
3 | Correct | 3 ms | 1272 KB | Output is correct |
4 | Correct | 47 ms | 7164 KB | Output is correct |
5 | Correct | 53 ms | 7288 KB | Output is correct |
6 | Correct | 50 ms | 7160 KB | Output is correct |
7 | Correct | 47 ms | 7160 KB | Output is correct |
8 | Correct | 56 ms | 7160 KB | Output is correct |
9 | Correct | 51 ms | 7132 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 48 ms | 7160 KB | Output is correct |
2 | Correct | 49 ms | 7160 KB | Output is correct |
3 | Correct | 3 ms | 1272 KB | Output is correct |
4 | Correct | 47 ms | 7164 KB | Output is correct |
5 | Correct | 53 ms | 7288 KB | Output is correct |
6 | Correct | 50 ms | 7160 KB | Output is correct |
7 | Correct | 47 ms | 7160 KB | Output is correct |
8 | Correct | 56 ms | 7160 KB | Output is correct |
9 | Correct | 51 ms | 7132 KB | Output is correct |
10 | Correct | 59 ms | 7160 KB | Output is correct |
11 | Correct | 62 ms | 7160 KB | Output is correct |
12 | Correct | 61 ms | 7184 KB | Output is correct |
13 | Correct | 59 ms | 7160 KB | Output is correct |
14 | Correct | 62 ms | 7228 KB | Output is correct |
15 | Correct | 62 ms | 7160 KB | Output is correct |
16 | Correct | 62 ms | 7160 KB | Output is correct |
17 | Correct | 55 ms | 7176 KB | Output is correct |
18 | Correct | 57 ms | 7160 KB | Output is correct |
19 | Correct | 60 ms | 7160 KB | Output is correct |
20 | Correct | 60 ms | 7160 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 48 ms | 7160 KB | Output is correct |
2 | Correct | 49 ms | 7160 KB | Output is correct |
3 | Correct | 3 ms | 1272 KB | Output is correct |
4 | Correct | 47 ms | 7164 KB | Output is correct |
5 | Correct | 53 ms | 7288 KB | Output is correct |
6 | Correct | 50 ms | 7160 KB | Output is correct |
7 | Correct | 47 ms | 7160 KB | Output is correct |
8 | Correct | 56 ms | 7160 KB | Output is correct |
9 | Correct | 51 ms | 7132 KB | Output is correct |
10 | Correct | 59 ms | 7160 KB | Output is correct |
11 | Correct | 62 ms | 7160 KB | Output is correct |
12 | Correct | 61 ms | 7184 KB | Output is correct |
13 | Correct | 59 ms | 7160 KB | Output is correct |
14 | Correct | 62 ms | 7228 KB | Output is correct |
15 | Correct | 62 ms | 7160 KB | Output is correct |
16 | Correct | 62 ms | 7160 KB | Output is correct |
17 | Correct | 55 ms | 7176 KB | Output is correct |
18 | Correct | 57 ms | 7160 KB | Output is correct |
19 | Correct | 60 ms | 7160 KB | Output is correct |
20 | Correct | 60 ms | 7160 KB | Output is correct |
21 | Correct | 83 ms | 7240 KB | Output is correct |
22 | Correct | 87 ms | 7288 KB | Output is correct |
23 | Correct | 75 ms | 7160 KB | Output is correct |
24 | Correct | 100 ms | 7224 KB | Output is correct |
25 | Correct | 99 ms | 7232 KB | Output is correct |
26 | Correct | 102 ms | 7160 KB | Output is correct |
27 | Correct | 101 ms | 7160 KB | Output is correct |
28 | Correct | 101 ms | 7160 KB | Output is correct |
29 | Correct | 100 ms | 7168 KB | Output is correct |
30 | Correct | 97 ms | 7160 KB | Output is correct |
31 | Correct | 103 ms | 7160 KB | Output is correct |
32 | Correct | 102 ms | 7160 KB | Output is correct |
33 | Correct | 93 ms | 7220 KB | Output is correct |
34 | Correct | 92 ms | 7160 KB | Output is correct |
35 | Correct | 99 ms | 7160 KB | Output is correct |
36 | Correct | 102 ms | 7160 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 48 ms | 7160 KB | Output is correct |
2 | Correct | 49 ms | 7160 KB | Output is correct |
3 | Correct | 3 ms | 1272 KB | Output is correct |
4 | Correct | 47 ms | 7164 KB | Output is correct |
5 | Correct | 53 ms | 7288 KB | Output is correct |
6 | Correct | 50 ms | 7160 KB | Output is correct |
7 | Correct | 47 ms | 7160 KB | Output is correct |
8 | Correct | 56 ms | 7160 KB | Output is correct |
9 | Correct | 51 ms | 7132 KB | Output is correct |
10 | Correct | 59 ms | 7160 KB | Output is correct |
11 | Correct | 62 ms | 7160 KB | Output is correct |
12 | Correct | 61 ms | 7184 KB | Output is correct |
13 | Correct | 59 ms | 7160 KB | Output is correct |
14 | Correct | 62 ms | 7228 KB | Output is correct |
15 | Correct | 62 ms | 7160 KB | Output is correct |
16 | Correct | 62 ms | 7160 KB | Output is correct |
17 | Correct | 55 ms | 7176 KB | Output is correct |
18 | Correct | 57 ms | 7160 KB | Output is correct |
19 | Correct | 60 ms | 7160 KB | Output is correct |
20 | Correct | 60 ms | 7160 KB | Output is correct |
21 | Correct | 83 ms | 7240 KB | Output is correct |
22 | Correct | 87 ms | 7288 KB | Output is correct |
23 | Correct | 75 ms | 7160 KB | Output is correct |
24 | Correct | 100 ms | 7224 KB | Output is correct |
25 | Correct | 99 ms | 7232 KB | Output is correct |
26 | Correct | 102 ms | 7160 KB | Output is correct |
27 | Correct | 101 ms | 7160 KB | Output is correct |
28 | Correct | 101 ms | 7160 KB | Output is correct |
29 | Correct | 100 ms | 7168 KB | Output is correct |
30 | Correct | 97 ms | 7160 KB | Output is correct |
31 | Correct | 103 ms | 7160 KB | Output is correct |
32 | Correct | 102 ms | 7160 KB | Output is correct |
33 | Correct | 93 ms | 7220 KB | Output is correct |
34 | Correct | 92 ms | 7160 KB | Output is correct |
35 | Correct | 99 ms | 7160 KB | Output is correct |
36 | Correct | 102 ms | 7160 KB | Output is correct |
37 | Correct | 173 ms | 7160 KB | Output is correct |
38 | Correct | 174 ms | 7288 KB | Output is correct |
39 | Correct | 164 ms | 7188 KB | Output is correct |
40 | Correct | 241 ms | 7236 KB | Output is correct |
41 | Correct | 177 ms | 7160 KB | Output is correct |
42 | Correct | 226 ms | 7160 KB | Output is correct |
43 | Correct | 253 ms | 7228 KB | Output is correct |
44 | Correct | 269 ms | 7160 KB | Output is correct |
45 | Correct | 262 ms | 7268 KB | Output is correct |
46 | Correct | 178 ms | 7160 KB | Output is correct |
47 | Correct | 227 ms | 7260 KB | Output is correct |
48 | Correct | 236 ms | 7288 KB | Output is correct |
49 | Correct | 186 ms | 7160 KB | Output is correct |
50 | Correct | 226 ms | 7160 KB | Output is correct |
51 | Correct | 42 ms | 1272 KB | Output is correct |
52 | Correct | 281 ms | 7160 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 48 ms | 7160 KB | Output is correct |
2 | Correct | 49 ms | 7160 KB | Output is correct |
3 | Correct | 3 ms | 1272 KB | Output is correct |
4 | Correct | 47 ms | 7164 KB | Output is correct |
5 | Correct | 53 ms | 7288 KB | Output is correct |
6 | Correct | 50 ms | 7160 KB | Output is correct |
7 | Correct | 47 ms | 7160 KB | Output is correct |
8 | Correct | 56 ms | 7160 KB | Output is correct |
9 | Correct | 51 ms | 7132 KB | Output is correct |
10 | Correct | 59 ms | 7160 KB | Output is correct |
11 | Correct | 62 ms | 7160 KB | Output is correct |
12 | Correct | 61 ms | 7184 KB | Output is correct |
13 | Correct | 59 ms | 7160 KB | Output is correct |
14 | Correct | 62 ms | 7228 KB | Output is correct |
15 | Correct | 62 ms | 7160 KB | Output is correct |
16 | Correct | 62 ms | 7160 KB | Output is correct |
17 | Correct | 55 ms | 7176 KB | Output is correct |
18 | Correct | 57 ms | 7160 KB | Output is correct |
19 | Correct | 60 ms | 7160 KB | Output is correct |
20 | Correct | 60 ms | 7160 KB | Output is correct |
21 | Correct | 83 ms | 7240 KB | Output is correct |
22 | Correct | 87 ms | 7288 KB | Output is correct |
23 | Correct | 75 ms | 7160 KB | Output is correct |
24 | Correct | 100 ms | 7224 KB | Output is correct |
25 | Correct | 99 ms | 7232 KB | Output is correct |
26 | Correct | 102 ms | 7160 KB | Output is correct |
27 | Correct | 101 ms | 7160 KB | Output is correct |
28 | Correct | 101 ms | 7160 KB | Output is correct |
29 | Correct | 100 ms | 7168 KB | Output is correct |
30 | Correct | 97 ms | 7160 KB | Output is correct |
31 | Correct | 103 ms | 7160 KB | Output is correct |
32 | Correct | 102 ms | 7160 KB | Output is correct |
33 | Correct | 93 ms | 7220 KB | Output is correct |
34 | Correct | 92 ms | 7160 KB | Output is correct |
35 | Correct | 99 ms | 7160 KB | Output is correct |
36 | Correct | 102 ms | 7160 KB | Output is correct |
37 | Correct | 173 ms | 7160 KB | Output is correct |
38 | Correct | 174 ms | 7288 KB | Output is correct |
39 | Correct | 164 ms | 7188 KB | Output is correct |
40 | Correct | 241 ms | 7236 KB | Output is correct |
41 | Correct | 177 ms | 7160 KB | Output is correct |
42 | Correct | 226 ms | 7160 KB | Output is correct |
43 | Correct | 253 ms | 7228 KB | Output is correct |
44 | Correct | 269 ms | 7160 KB | Output is correct |
45 | Correct | 262 ms | 7268 KB | Output is correct |
46 | Correct | 178 ms | 7160 KB | Output is correct |
47 | Correct | 227 ms | 7260 KB | Output is correct |
48 | Correct | 236 ms | 7288 KB | Output is correct |
49 | Correct | 186 ms | 7160 KB | Output is correct |
50 | Correct | 226 ms | 7160 KB | Output is correct |
51 | Correct | 42 ms | 1272 KB | Output is correct |
52 | Correct | 281 ms | 7160 KB | Output is correct |
53 | Correct | 285 ms | 7260 KB | Output is correct |
54 | Correct | 350 ms | 7224 KB | Output is correct |
55 | Correct | 461 ms | 7288 KB | Output is correct |
56 | Correct | 310 ms | 7160 KB | Output is correct |
57 | Correct | 493 ms | 7228 KB | Output is correct |
58 | Correct | 366 ms | 7232 KB | Output is correct |
59 | Correct | 404 ms | 7232 KB | Output is correct |
60 | Correct | 58 ms | 1272 KB | Output is correct |
61 | Correct | 416 ms | 7160 KB | Output is correct |
62 | Correct | 403 ms | 7132 KB | Output is correct |
63 | Correct | 409 ms | 7160 KB | Output is correct |
64 | Correct | 401 ms | 7272 KB | Output is correct |
65 | Correct | 206 ms | 7160 KB | Output is correct |
66 | Correct | 240 ms | 7304 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 48 ms | 7160 KB | Output is correct |
2 | Correct | 49 ms | 7160 KB | Output is correct |
3 | Correct | 3 ms | 1272 KB | Output is correct |
4 | Correct | 47 ms | 7164 KB | Output is correct |
5 | Correct | 53 ms | 7288 KB | Output is correct |
6 | Correct | 50 ms | 7160 KB | Output is correct |
7 | Correct | 47 ms | 7160 KB | Output is correct |
8 | Correct | 56 ms | 7160 KB | Output is correct |
9 | Correct | 51 ms | 7132 KB | Output is correct |
10 | Correct | 59 ms | 7160 KB | Output is correct |
11 | Correct | 62 ms | 7160 KB | Output is correct |
12 | Correct | 61 ms | 7184 KB | Output is correct |
13 | Correct | 59 ms | 7160 KB | Output is correct |
14 | Correct | 62 ms | 7228 KB | Output is correct |
15 | Correct | 62 ms | 7160 KB | Output is correct |
16 | Correct | 62 ms | 7160 KB | Output is correct |
17 | Correct | 55 ms | 7176 KB | Output is correct |
18 | Correct | 57 ms | 7160 KB | Output is correct |
19 | Correct | 60 ms | 7160 KB | Output is correct |
20 | Correct | 60 ms | 7160 KB | Output is correct |
21 | Correct | 83 ms | 7240 KB | Output is correct |
22 | Correct | 87 ms | 7288 KB | Output is correct |
23 | Correct | 75 ms | 7160 KB | Output is correct |
24 | Correct | 100 ms | 7224 KB | Output is correct |
25 | Correct | 99 ms | 7232 KB | Output is correct |
26 | Correct | 102 ms | 7160 KB | Output is correct |
27 | Correct | 101 ms | 7160 KB | Output is correct |
28 | Correct | 101 ms | 7160 KB | Output is correct |
29 | Correct | 100 ms | 7168 KB | Output is correct |
30 | Correct | 97 ms | 7160 KB | Output is correct |
31 | Correct | 103 ms | 7160 KB | Output is correct |
32 | Correct | 102 ms | 7160 KB | Output is correct |
33 | Correct | 93 ms | 7220 KB | Output is correct |
34 | Correct | 92 ms | 7160 KB | Output is correct |
35 | Correct | 99 ms | 7160 KB | Output is correct |
36 | Correct | 102 ms | 7160 KB | Output is correct |
37 | Correct | 173 ms | 7160 KB | Output is correct |
38 | Correct | 174 ms | 7288 KB | Output is correct |
39 | Correct | 164 ms | 7188 KB | Output is correct |
40 | Correct | 241 ms | 7236 KB | Output is correct |
41 | Correct | 177 ms | 7160 KB | Output is correct |
42 | Correct | 226 ms | 7160 KB | Output is correct |
43 | Correct | 253 ms | 7228 KB | Output is correct |
44 | Correct | 269 ms | 7160 KB | Output is correct |
45 | Correct | 262 ms | 7268 KB | Output is correct |
46 | Correct | 178 ms | 7160 KB | Output is correct |
47 | Correct | 227 ms | 7260 KB | Output is correct |
48 | Correct | 236 ms | 7288 KB | Output is correct |
49 | Correct | 186 ms | 7160 KB | Output is correct |
50 | Correct | 226 ms | 7160 KB | Output is correct |
51 | Correct | 42 ms | 1272 KB | Output is correct |
52 | Correct | 281 ms | 7160 KB | Output is correct |
53 | Correct | 285 ms | 7260 KB | Output is correct |
54 | Correct | 350 ms | 7224 KB | Output is correct |
55 | Correct | 461 ms | 7288 KB | Output is correct |
56 | Correct | 310 ms | 7160 KB | Output is correct |
57 | Correct | 493 ms | 7228 KB | Output is correct |
58 | Correct | 366 ms | 7232 KB | Output is correct |
59 | Correct | 404 ms | 7232 KB | Output is correct |
60 | Correct | 58 ms | 1272 KB | Output is correct |
61 | Correct | 416 ms | 7160 KB | Output is correct |
62 | Correct | 403 ms | 7132 KB | Output is correct |
63 | Correct | 409 ms | 7160 KB | Output is correct |
64 | Correct | 401 ms | 7272 KB | Output is correct |
65 | Correct | 206 ms | 7160 KB | Output is correct |
66 | Correct | 240 ms | 7304 KB | Output is correct |
67 | Correct | 462 ms | 7128 KB | Output is correct |
68 | Correct | 81 ms | 1272 KB | Output is correct |
69 | Incorrect | 738 ms | 7992 KB | Output isn't correct |
70 | Halted | 0 ms | 0 KB | - |