#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 505, M = 1e7 + 5, MOD = 1e9 + 9;
int n, a[N], sum, ssum;
bool used[M];
long long dp[M];
inline void Add(int val){
sum += val;
for(int i = sum; i >= 0; i--){
dp[i + val] += dp[i];
}
}
inline void Del(int val){
for(int i = 0; i <= sum; i++){
dp[i + val] -= dp[i];
}
sum -= val;
}
main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n;
dp[0] = 1;
for(int i = 1; i <= n; i++){
cin >> a[i];
ssum += a[i];
Add(a[i]);
}
for(int i = 1; i <= ssum; i++){
used[i] = true;
}
if(ssum % 2 || dp[ssum / 2] == 0){
return cout << 0, 0;
}
for(int i = 1; i <= n; i++){
Del(a[i]);
for(int j = 1; j <= ssum; j++){
if((sum + j) % 2 || dp[(sum + j) / 2] == 0){
used[j] = false;
}
}
Add(a[i]);
}
vector < int > ans;
for(int i = 1; i <= ssum; i++){
if(used[i]){
ans.push_back(i);
}
}
cout << (int)ans.size() << "\n";
for(auto it : ans){
cout << it << " ";
}
}
Compilation message
bootfall.cpp:29:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
380 KB |
Output is correct |
21 |
Correct |
2 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
3 ms |
376 KB |
Output is correct |
24 |
Correct |
3 ms |
504 KB |
Output is correct |
25 |
Correct |
5 ms |
504 KB |
Output is correct |
26 |
Correct |
5 ms |
504 KB |
Output is correct |
27 |
Correct |
5 ms |
504 KB |
Output is correct |
28 |
Correct |
5 ms |
504 KB |
Output is correct |
29 |
Correct |
5 ms |
504 KB |
Output is correct |
30 |
Correct |
3 ms |
376 KB |
Output is correct |
31 |
Correct |
4 ms |
504 KB |
Output is correct |
32 |
Correct |
3 ms |
504 KB |
Output is correct |
33 |
Correct |
5 ms |
376 KB |
Output is correct |
34 |
Correct |
5 ms |
504 KB |
Output is correct |
35 |
Correct |
5 ms |
376 KB |
Output is correct |
36 |
Correct |
4 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
380 KB |
Output is correct |
21 |
Correct |
2 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
3 ms |
376 KB |
Output is correct |
24 |
Correct |
3 ms |
504 KB |
Output is correct |
25 |
Correct |
5 ms |
504 KB |
Output is correct |
26 |
Correct |
5 ms |
504 KB |
Output is correct |
27 |
Correct |
5 ms |
504 KB |
Output is correct |
28 |
Correct |
5 ms |
504 KB |
Output is correct |
29 |
Correct |
5 ms |
504 KB |
Output is correct |
30 |
Correct |
3 ms |
376 KB |
Output is correct |
31 |
Correct |
4 ms |
504 KB |
Output is correct |
32 |
Correct |
3 ms |
504 KB |
Output is correct |
33 |
Correct |
5 ms |
376 KB |
Output is correct |
34 |
Correct |
5 ms |
504 KB |
Output is correct |
35 |
Correct |
5 ms |
376 KB |
Output is correct |
36 |
Correct |
4 ms |
504 KB |
Output is correct |
37 |
Correct |
14 ms |
760 KB |
Output is correct |
38 |
Correct |
13 ms |
760 KB |
Output is correct |
39 |
Correct |
44 ms |
888 KB |
Output is correct |
40 |
Correct |
27 ms |
1020 KB |
Output is correct |
41 |
Correct |
59 ms |
1076 KB |
Output is correct |
42 |
Correct |
24 ms |
888 KB |
Output is correct |
43 |
Correct |
44 ms |
1268 KB |
Output is correct |
44 |
Correct |
45 ms |
1272 KB |
Output is correct |
45 |
Correct |
45 ms |
1400 KB |
Output is correct |
46 |
Correct |
26 ms |
636 KB |
Output is correct |
47 |
Correct |
27 ms |
1016 KB |
Output is correct |
48 |
Correct |
46 ms |
1360 KB |
Output is correct |
49 |
Correct |
50 ms |
1016 KB |
Output is correct |
50 |
Correct |
27 ms |
1016 KB |
Output is correct |
51 |
Correct |
5 ms |
632 KB |
Output is correct |
52 |
Correct |
57 ms |
1528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
380 KB |
Output is correct |
21 |
Correct |
2 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
3 ms |
376 KB |
Output is correct |
24 |
Correct |
3 ms |
504 KB |
Output is correct |
25 |
Correct |
5 ms |
504 KB |
Output is correct |
26 |
Correct |
5 ms |
504 KB |
Output is correct |
27 |
Correct |
5 ms |
504 KB |
Output is correct |
28 |
Correct |
5 ms |
504 KB |
Output is correct |
29 |
Correct |
5 ms |
504 KB |
Output is correct |
30 |
Correct |
3 ms |
376 KB |
Output is correct |
31 |
Correct |
4 ms |
504 KB |
Output is correct |
32 |
Correct |
3 ms |
504 KB |
Output is correct |
33 |
Correct |
5 ms |
376 KB |
Output is correct |
34 |
Correct |
5 ms |
504 KB |
Output is correct |
35 |
Correct |
5 ms |
376 KB |
Output is correct |
36 |
Correct |
4 ms |
504 KB |
Output is correct |
37 |
Correct |
14 ms |
760 KB |
Output is correct |
38 |
Correct |
13 ms |
760 KB |
Output is correct |
39 |
Correct |
44 ms |
888 KB |
Output is correct |
40 |
Correct |
27 ms |
1020 KB |
Output is correct |
41 |
Correct |
59 ms |
1076 KB |
Output is correct |
42 |
Correct |
24 ms |
888 KB |
Output is correct |
43 |
Correct |
44 ms |
1268 KB |
Output is correct |
44 |
Correct |
45 ms |
1272 KB |
Output is correct |
45 |
Correct |
45 ms |
1400 KB |
Output is correct |
46 |
Correct |
26 ms |
636 KB |
Output is correct |
47 |
Correct |
27 ms |
1016 KB |
Output is correct |
48 |
Correct |
46 ms |
1360 KB |
Output is correct |
49 |
Correct |
50 ms |
1016 KB |
Output is correct |
50 |
Correct |
27 ms |
1016 KB |
Output is correct |
51 |
Correct |
5 ms |
632 KB |
Output is correct |
52 |
Correct |
57 ms |
1528 KB |
Output is correct |
53 |
Correct |
40 ms |
1144 KB |
Output is correct |
54 |
Correct |
58 ms |
1396 KB |
Output is correct |
55 |
Correct |
119 ms |
2164 KB |
Output is correct |
56 |
Correct |
52 ms |
1528 KB |
Output is correct |
57 |
Correct |
129 ms |
2292 KB |
Output is correct |
58 |
Correct |
67 ms |
1528 KB |
Output is correct |
59 |
Correct |
83 ms |
1652 KB |
Output is correct |
60 |
Correct |
10 ms |
888 KB |
Output is correct |
61 |
Correct |
89 ms |
1908 KB |
Output is correct |
62 |
Correct |
93 ms |
2032 KB |
Output is correct |
63 |
Correct |
105 ms |
2164 KB |
Output is correct |
64 |
Correct |
96 ms |
2164 KB |
Output is correct |
65 |
Correct |
50 ms |
760 KB |
Output is correct |
66 |
Correct |
52 ms |
984 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
380 KB |
Output is correct |
21 |
Correct |
2 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
3 ms |
376 KB |
Output is correct |
24 |
Correct |
3 ms |
504 KB |
Output is correct |
25 |
Correct |
5 ms |
504 KB |
Output is correct |
26 |
Correct |
5 ms |
504 KB |
Output is correct |
27 |
Correct |
5 ms |
504 KB |
Output is correct |
28 |
Correct |
5 ms |
504 KB |
Output is correct |
29 |
Correct |
5 ms |
504 KB |
Output is correct |
30 |
Correct |
3 ms |
376 KB |
Output is correct |
31 |
Correct |
4 ms |
504 KB |
Output is correct |
32 |
Correct |
3 ms |
504 KB |
Output is correct |
33 |
Correct |
5 ms |
376 KB |
Output is correct |
34 |
Correct |
5 ms |
504 KB |
Output is correct |
35 |
Correct |
5 ms |
376 KB |
Output is correct |
36 |
Correct |
4 ms |
504 KB |
Output is correct |
37 |
Correct |
14 ms |
760 KB |
Output is correct |
38 |
Correct |
13 ms |
760 KB |
Output is correct |
39 |
Correct |
44 ms |
888 KB |
Output is correct |
40 |
Correct |
27 ms |
1020 KB |
Output is correct |
41 |
Correct |
59 ms |
1076 KB |
Output is correct |
42 |
Correct |
24 ms |
888 KB |
Output is correct |
43 |
Correct |
44 ms |
1268 KB |
Output is correct |
44 |
Correct |
45 ms |
1272 KB |
Output is correct |
45 |
Correct |
45 ms |
1400 KB |
Output is correct |
46 |
Correct |
26 ms |
636 KB |
Output is correct |
47 |
Correct |
27 ms |
1016 KB |
Output is correct |
48 |
Correct |
46 ms |
1360 KB |
Output is correct |
49 |
Correct |
50 ms |
1016 KB |
Output is correct |
50 |
Correct |
27 ms |
1016 KB |
Output is correct |
51 |
Correct |
5 ms |
632 KB |
Output is correct |
52 |
Correct |
57 ms |
1528 KB |
Output is correct |
53 |
Correct |
40 ms |
1144 KB |
Output is correct |
54 |
Correct |
58 ms |
1396 KB |
Output is correct |
55 |
Correct |
119 ms |
2164 KB |
Output is correct |
56 |
Correct |
52 ms |
1528 KB |
Output is correct |
57 |
Correct |
129 ms |
2292 KB |
Output is correct |
58 |
Correct |
67 ms |
1528 KB |
Output is correct |
59 |
Correct |
83 ms |
1652 KB |
Output is correct |
60 |
Correct |
10 ms |
888 KB |
Output is correct |
61 |
Correct |
89 ms |
1908 KB |
Output is correct |
62 |
Correct |
93 ms |
2032 KB |
Output is correct |
63 |
Correct |
105 ms |
2164 KB |
Output is correct |
64 |
Correct |
96 ms |
2164 KB |
Output is correct |
65 |
Correct |
50 ms |
760 KB |
Output is correct |
66 |
Correct |
52 ms |
984 KB |
Output is correct |
67 |
Correct |
97 ms |
1684 KB |
Output is correct |
68 |
Correct |
27 ms |
1528 KB |
Output is correct |
69 |
Correct |
325 ms |
3824 KB |
Output is correct |
70 |
Correct |
193 ms |
2548 KB |
Output is correct |
71 |
Correct |
189 ms |
2548 KB |
Output is correct |
72 |
Correct |
185 ms |
1540 KB |
Output is correct |
73 |
Correct |
189 ms |
1536 KB |
Output is correct |
74 |
Correct |
339 ms |
4080 KB |
Output is correct |
75 |
Correct |
262 ms |
3308 KB |
Output is correct |
76 |
Correct |
359 ms |
4076 KB |
Output is correct |
77 |
Correct |
339 ms |
4204 KB |
Output is correct |