#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second
using namespace std;
using ll = long long;
const int N = 500+5 , inf = 2e9 + 7;
const ll INF = 1e18 , mod = 1e9+7 , P = 6547;
int a[N];
bitset<500*250> b1 , b2 , b3;
void solve() {
int n;
cin >> n;
int sum = 0;
int cnt[2];
cnt[0]=cnt[1]=0;
for(int i = 1; i <= n; i ++) {
cin >> a[i];
sum += a[i];
cnt[a[i]%2] = 1;
}
if(sum%2 || cnt[0]==cnt[1]) {
cout << 0;
return;
}
for(int i = 0; i <= n; i ++) {
b3.reset();
for(int j = 1; j <= n; j ++) {
if(i == j) continue;
if(i == 0) {
b2 |= (b2 << a[j]);
b2[a[j]] = 1;
}
else {
b3 |= (b3 << a[j]);
b3[a[j]] = 1;
}
}
if(i) b3 <<= a[i]/2;
if(i == 1) b1 = b3;
if(i > 1) b1 &= b3;
}
if(!b2[sum/2]) {
cout << 0;
return;
}
vector<int> ans;
int sta = 0;
if(cnt[1]) sta = 1;
for(int i = sta; i <= sum; i += 2) {
int cur = (sum+i)/2;
if(b1[cur]) ans.push_back(i);
}
sort(all(ans));
cout << ans.size() << '\n';
for(auto to: ans) {
cout << to << ' ';
}
}
/*
1 2 1 2 2
*/
main() {
ios;
int tt = 1;
//cin >> tt;
while(tt --) {
solve();
}
return 0;
}
Compilation message
bootfall.cpp:73:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
73 | main() {
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
5 ms |
364 KB |
Output is correct |
11 |
Correct |
4 ms |
364 KB |
Output is correct |
12 |
Correct |
5 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
4 ms |
364 KB |
Output is correct |
15 |
Correct |
4 ms |
364 KB |
Output is correct |
16 |
Correct |
5 ms |
364 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
364 KB |
Output is correct |
19 |
Correct |
4 ms |
364 KB |
Output is correct |
20 |
Correct |
6 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
5 ms |
364 KB |
Output is correct |
11 |
Correct |
4 ms |
364 KB |
Output is correct |
12 |
Correct |
5 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
4 ms |
364 KB |
Output is correct |
15 |
Correct |
4 ms |
364 KB |
Output is correct |
16 |
Correct |
5 ms |
364 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
364 KB |
Output is correct |
19 |
Correct |
4 ms |
364 KB |
Output is correct |
20 |
Correct |
6 ms |
364 KB |
Output is correct |
21 |
Correct |
18 ms |
492 KB |
Output is correct |
22 |
Correct |
25 ms |
384 KB |
Output is correct |
23 |
Correct |
11 ms |
492 KB |
Output is correct |
24 |
Correct |
38 ms |
492 KB |
Output is correct |
25 |
Correct |
39 ms |
492 KB |
Output is correct |
26 |
Correct |
43 ms |
468 KB |
Output is correct |
27 |
Correct |
43 ms |
492 KB |
Output is correct |
28 |
Correct |
43 ms |
492 KB |
Output is correct |
29 |
Correct |
44 ms |
364 KB |
Output is correct |
30 |
Correct |
1 ms |
364 KB |
Output is correct |
31 |
Correct |
43 ms |
492 KB |
Output is correct |
32 |
Correct |
43 ms |
492 KB |
Output is correct |
33 |
Correct |
43 ms |
364 KB |
Output is correct |
34 |
Correct |
43 ms |
384 KB |
Output is correct |
35 |
Correct |
43 ms |
364 KB |
Output is correct |
36 |
Correct |
43 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
5 ms |
364 KB |
Output is correct |
11 |
Correct |
4 ms |
364 KB |
Output is correct |
12 |
Correct |
5 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
4 ms |
364 KB |
Output is correct |
15 |
Correct |
4 ms |
364 KB |
Output is correct |
16 |
Correct |
5 ms |
364 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
364 KB |
Output is correct |
19 |
Correct |
4 ms |
364 KB |
Output is correct |
20 |
Correct |
6 ms |
364 KB |
Output is correct |
21 |
Correct |
18 ms |
492 KB |
Output is correct |
22 |
Correct |
25 ms |
384 KB |
Output is correct |
23 |
Correct |
11 ms |
492 KB |
Output is correct |
24 |
Correct |
38 ms |
492 KB |
Output is correct |
25 |
Correct |
39 ms |
492 KB |
Output is correct |
26 |
Correct |
43 ms |
468 KB |
Output is correct |
27 |
Correct |
43 ms |
492 KB |
Output is correct |
28 |
Correct |
43 ms |
492 KB |
Output is correct |
29 |
Correct |
44 ms |
364 KB |
Output is correct |
30 |
Correct |
1 ms |
364 KB |
Output is correct |
31 |
Correct |
43 ms |
492 KB |
Output is correct |
32 |
Correct |
43 ms |
492 KB |
Output is correct |
33 |
Correct |
43 ms |
364 KB |
Output is correct |
34 |
Correct |
43 ms |
384 KB |
Output is correct |
35 |
Correct |
43 ms |
364 KB |
Output is correct |
36 |
Correct |
43 ms |
492 KB |
Output is correct |
37 |
Correct |
177 ms |
620 KB |
Output is correct |
38 |
Correct |
170 ms |
620 KB |
Output is correct |
39 |
Correct |
258 ms |
364 KB |
Output is correct |
40 |
Correct |
315 ms |
620 KB |
Output is correct |
41 |
Correct |
303 ms |
364 KB |
Output is correct |
42 |
Correct |
263 ms |
620 KB |
Output is correct |
43 |
Correct |
252 ms |
748 KB |
Output is correct |
44 |
Correct |
264 ms |
748 KB |
Output is correct |
45 |
Correct |
265 ms |
748 KB |
Output is correct |
46 |
Correct |
308 ms |
492 KB |
Output is correct |
47 |
Correct |
276 ms |
620 KB |
Output is correct |
48 |
Correct |
263 ms |
748 KB |
Output is correct |
49 |
Correct |
263 ms |
492 KB |
Output is correct |
50 |
Correct |
262 ms |
620 KB |
Output is correct |
51 |
Correct |
1 ms |
364 KB |
Output is correct |
52 |
Correct |
308 ms |
876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
5 ms |
364 KB |
Output is correct |
11 |
Correct |
4 ms |
364 KB |
Output is correct |
12 |
Correct |
5 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
4 ms |
364 KB |
Output is correct |
15 |
Correct |
4 ms |
364 KB |
Output is correct |
16 |
Correct |
5 ms |
364 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
364 KB |
Output is correct |
19 |
Correct |
4 ms |
364 KB |
Output is correct |
20 |
Correct |
6 ms |
364 KB |
Output is correct |
21 |
Correct |
18 ms |
492 KB |
Output is correct |
22 |
Correct |
25 ms |
384 KB |
Output is correct |
23 |
Correct |
11 ms |
492 KB |
Output is correct |
24 |
Correct |
38 ms |
492 KB |
Output is correct |
25 |
Correct |
39 ms |
492 KB |
Output is correct |
26 |
Correct |
43 ms |
468 KB |
Output is correct |
27 |
Correct |
43 ms |
492 KB |
Output is correct |
28 |
Correct |
43 ms |
492 KB |
Output is correct |
29 |
Correct |
44 ms |
364 KB |
Output is correct |
30 |
Correct |
1 ms |
364 KB |
Output is correct |
31 |
Correct |
43 ms |
492 KB |
Output is correct |
32 |
Correct |
43 ms |
492 KB |
Output is correct |
33 |
Correct |
43 ms |
364 KB |
Output is correct |
34 |
Correct |
43 ms |
384 KB |
Output is correct |
35 |
Correct |
43 ms |
364 KB |
Output is correct |
36 |
Correct |
43 ms |
492 KB |
Output is correct |
37 |
Correct |
177 ms |
620 KB |
Output is correct |
38 |
Correct |
170 ms |
620 KB |
Output is correct |
39 |
Correct |
258 ms |
364 KB |
Output is correct |
40 |
Correct |
315 ms |
620 KB |
Output is correct |
41 |
Correct |
303 ms |
364 KB |
Output is correct |
42 |
Correct |
263 ms |
620 KB |
Output is correct |
43 |
Correct |
252 ms |
748 KB |
Output is correct |
44 |
Correct |
264 ms |
748 KB |
Output is correct |
45 |
Correct |
265 ms |
748 KB |
Output is correct |
46 |
Correct |
308 ms |
492 KB |
Output is correct |
47 |
Correct |
276 ms |
620 KB |
Output is correct |
48 |
Correct |
263 ms |
748 KB |
Output is correct |
49 |
Correct |
263 ms |
492 KB |
Output is correct |
50 |
Correct |
262 ms |
620 KB |
Output is correct |
51 |
Correct |
1 ms |
364 KB |
Output is correct |
52 |
Correct |
308 ms |
876 KB |
Output is correct |
53 |
Correct |
376 ms |
748 KB |
Output is correct |
54 |
Correct |
528 ms |
1024 KB |
Output is correct |
55 |
Correct |
524 ms |
1008 KB |
Output is correct |
56 |
Correct |
395 ms |
768 KB |
Output is correct |
57 |
Correct |
534 ms |
1136 KB |
Output is correct |
58 |
Correct |
517 ms |
876 KB |
Output is correct |
59 |
Correct |
522 ms |
1008 KB |
Output is correct |
60 |
Correct |
1 ms |
364 KB |
Output is correct |
61 |
Correct |
518 ms |
1008 KB |
Output is correct |
62 |
Correct |
437 ms |
1008 KB |
Output is correct |
63 |
Correct |
431 ms |
1008 KB |
Output is correct |
64 |
Correct |
425 ms |
984 KB |
Output is correct |
65 |
Correct |
415 ms |
492 KB |
Output is correct |
66 |
Correct |
403 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
5 ms |
364 KB |
Output is correct |
11 |
Correct |
4 ms |
364 KB |
Output is correct |
12 |
Correct |
5 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
4 ms |
364 KB |
Output is correct |
15 |
Correct |
4 ms |
364 KB |
Output is correct |
16 |
Correct |
5 ms |
364 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
364 KB |
Output is correct |
19 |
Correct |
4 ms |
364 KB |
Output is correct |
20 |
Correct |
6 ms |
364 KB |
Output is correct |
21 |
Correct |
18 ms |
492 KB |
Output is correct |
22 |
Correct |
25 ms |
384 KB |
Output is correct |
23 |
Correct |
11 ms |
492 KB |
Output is correct |
24 |
Correct |
38 ms |
492 KB |
Output is correct |
25 |
Correct |
39 ms |
492 KB |
Output is correct |
26 |
Correct |
43 ms |
468 KB |
Output is correct |
27 |
Correct |
43 ms |
492 KB |
Output is correct |
28 |
Correct |
43 ms |
492 KB |
Output is correct |
29 |
Correct |
44 ms |
364 KB |
Output is correct |
30 |
Correct |
1 ms |
364 KB |
Output is correct |
31 |
Correct |
43 ms |
492 KB |
Output is correct |
32 |
Correct |
43 ms |
492 KB |
Output is correct |
33 |
Correct |
43 ms |
364 KB |
Output is correct |
34 |
Correct |
43 ms |
384 KB |
Output is correct |
35 |
Correct |
43 ms |
364 KB |
Output is correct |
36 |
Correct |
43 ms |
492 KB |
Output is correct |
37 |
Correct |
177 ms |
620 KB |
Output is correct |
38 |
Correct |
170 ms |
620 KB |
Output is correct |
39 |
Correct |
258 ms |
364 KB |
Output is correct |
40 |
Correct |
315 ms |
620 KB |
Output is correct |
41 |
Correct |
303 ms |
364 KB |
Output is correct |
42 |
Correct |
263 ms |
620 KB |
Output is correct |
43 |
Correct |
252 ms |
748 KB |
Output is correct |
44 |
Correct |
264 ms |
748 KB |
Output is correct |
45 |
Correct |
265 ms |
748 KB |
Output is correct |
46 |
Correct |
308 ms |
492 KB |
Output is correct |
47 |
Correct |
276 ms |
620 KB |
Output is correct |
48 |
Correct |
263 ms |
748 KB |
Output is correct |
49 |
Correct |
263 ms |
492 KB |
Output is correct |
50 |
Correct |
262 ms |
620 KB |
Output is correct |
51 |
Correct |
1 ms |
364 KB |
Output is correct |
52 |
Correct |
308 ms |
876 KB |
Output is correct |
53 |
Correct |
376 ms |
748 KB |
Output is correct |
54 |
Correct |
528 ms |
1024 KB |
Output is correct |
55 |
Correct |
524 ms |
1008 KB |
Output is correct |
56 |
Correct |
395 ms |
768 KB |
Output is correct |
57 |
Correct |
534 ms |
1136 KB |
Output is correct |
58 |
Correct |
517 ms |
876 KB |
Output is correct |
59 |
Correct |
522 ms |
1008 KB |
Output is correct |
60 |
Correct |
1 ms |
364 KB |
Output is correct |
61 |
Correct |
518 ms |
1008 KB |
Output is correct |
62 |
Correct |
437 ms |
1008 KB |
Output is correct |
63 |
Correct |
431 ms |
1008 KB |
Output is correct |
64 |
Correct |
425 ms |
984 KB |
Output is correct |
65 |
Correct |
415 ms |
492 KB |
Output is correct |
66 |
Correct |
403 ms |
492 KB |
Output is correct |
67 |
Correct |
678 ms |
880 KB |
Output is correct |
68 |
Execution timed out |
1038 ms |
500 KB |
Time limit exceeded |
69 |
Halted |
0 ms |
0 KB |
- |