#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
int n,tot;
int arr[505],dp[250005],curr[250005];
bitset<250005> bs[505];
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for(int i=1;i<=n;i++){
cin >> arr[i];
tot += arr[i];
}
dp[0] = 1;
for(int i=1;i<=n;i++){
for(int j=250000;j>=arr[i];j--){
dp[j] += dp[j-arr[i]];
}
}
if(tot%2 or dp[tot/2]==0){
cout << 0 << "\n";
cout << "\n";
return 0;
}
for(int j=1;j<=n;j++){
for(int i=0;i<=250000;i++){
curr[i] = dp[i];
if(i>=arr[j]){
curr[i] -= curr[i-arr[j]];
}
if(curr[i]!=0){
bs[j][i] = true;
}
}
}
vector<int> ans;
for(int i=1;i<=250000;i++){
bool yes = true;
for(int j=1;j<=n;j++){
if((tot-arr[j]+i)%2){
yes = false;
break;
}
int x = (tot-arr[j]+i)/2;
if(dp[x]==0){
yes = false;
break;
}
if(!bs[j][x]){
yes = false;
break;
}
}
if(yes){
ans.push_back(i);
}
}
cout << ans.size() << "\n";
for(int i:ans){
cout << i << " ";
}
cout << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
4180 KB |
Output is correct |
2 |
Correct |
4 ms |
4180 KB |
Output is correct |
3 |
Correct |
2 ms |
2260 KB |
Output is correct |
4 |
Correct |
4 ms |
4264 KB |
Output is correct |
5 |
Correct |
6 ms |
4252 KB |
Output is correct |
6 |
Correct |
5 ms |
4180 KB |
Output is correct |
7 |
Correct |
4 ms |
4180 KB |
Output is correct |
8 |
Correct |
6 ms |
4180 KB |
Output is correct |
9 |
Correct |
6 ms |
4180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
4180 KB |
Output is correct |
2 |
Correct |
4 ms |
4180 KB |
Output is correct |
3 |
Correct |
2 ms |
2260 KB |
Output is correct |
4 |
Correct |
4 ms |
4264 KB |
Output is correct |
5 |
Correct |
6 ms |
4252 KB |
Output is correct |
6 |
Correct |
5 ms |
4180 KB |
Output is correct |
7 |
Correct |
4 ms |
4180 KB |
Output is correct |
8 |
Correct |
6 ms |
4180 KB |
Output is correct |
9 |
Correct |
6 ms |
4180 KB |
Output is correct |
10 |
Correct |
12 ms |
4308 KB |
Output is correct |
11 |
Correct |
13 ms |
4308 KB |
Output is correct |
12 |
Correct |
13 ms |
4308 KB |
Output is correct |
13 |
Correct |
11 ms |
4308 KB |
Output is correct |
14 |
Correct |
11 ms |
4340 KB |
Output is correct |
15 |
Correct |
13 ms |
4364 KB |
Output is correct |
16 |
Correct |
14 ms |
4308 KB |
Output is correct |
17 |
Correct |
9 ms |
4308 KB |
Output is correct |
18 |
Correct |
10 ms |
4308 KB |
Output is correct |
19 |
Correct |
11 ms |
4308 KB |
Output is correct |
20 |
Correct |
13 ms |
4352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
4180 KB |
Output is correct |
2 |
Correct |
4 ms |
4180 KB |
Output is correct |
3 |
Correct |
2 ms |
2260 KB |
Output is correct |
4 |
Correct |
4 ms |
4264 KB |
Output is correct |
5 |
Correct |
6 ms |
4252 KB |
Output is correct |
6 |
Correct |
5 ms |
4180 KB |
Output is correct |
7 |
Correct |
4 ms |
4180 KB |
Output is correct |
8 |
Correct |
6 ms |
4180 KB |
Output is correct |
9 |
Correct |
6 ms |
4180 KB |
Output is correct |
10 |
Correct |
12 ms |
4308 KB |
Output is correct |
11 |
Correct |
13 ms |
4308 KB |
Output is correct |
12 |
Correct |
13 ms |
4308 KB |
Output is correct |
13 |
Correct |
11 ms |
4308 KB |
Output is correct |
14 |
Correct |
11 ms |
4340 KB |
Output is correct |
15 |
Correct |
13 ms |
4364 KB |
Output is correct |
16 |
Correct |
14 ms |
4308 KB |
Output is correct |
17 |
Correct |
9 ms |
4308 KB |
Output is correct |
18 |
Correct |
10 ms |
4308 KB |
Output is correct |
19 |
Correct |
11 ms |
4308 KB |
Output is correct |
20 |
Correct |
13 ms |
4352 KB |
Output is correct |
21 |
Correct |
24 ms |
4476 KB |
Output is correct |
22 |
Correct |
30 ms |
4496 KB |
Output is correct |
23 |
Correct |
19 ms |
4436 KB |
Output is correct |
24 |
Correct |
34 ms |
4696 KB |
Output is correct |
25 |
Correct |
33 ms |
4700 KB |
Output is correct |
26 |
Correct |
35 ms |
4760 KB |
Output is correct |
27 |
Correct |
34 ms |
4692 KB |
Output is correct |
28 |
Correct |
34 ms |
4772 KB |
Output is correct |
29 |
Correct |
34 ms |
4692 KB |
Output is correct |
30 |
Correct |
37 ms |
4684 KB |
Output is correct |
31 |
Correct |
35 ms |
4788 KB |
Output is correct |
32 |
Correct |
39 ms |
4788 KB |
Output is correct |
33 |
Correct |
34 ms |
4636 KB |
Output is correct |
34 |
Correct |
33 ms |
4728 KB |
Output is correct |
35 |
Correct |
34 ms |
4756 KB |
Output is correct |
36 |
Correct |
36 ms |
4660 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
4180 KB |
Output is correct |
2 |
Correct |
4 ms |
4180 KB |
Output is correct |
3 |
Correct |
2 ms |
2260 KB |
Output is correct |
4 |
Correct |
4 ms |
4264 KB |
Output is correct |
5 |
Correct |
6 ms |
4252 KB |
Output is correct |
6 |
Correct |
5 ms |
4180 KB |
Output is correct |
7 |
Correct |
4 ms |
4180 KB |
Output is correct |
8 |
Correct |
6 ms |
4180 KB |
Output is correct |
9 |
Correct |
6 ms |
4180 KB |
Output is correct |
10 |
Correct |
12 ms |
4308 KB |
Output is correct |
11 |
Correct |
13 ms |
4308 KB |
Output is correct |
12 |
Correct |
13 ms |
4308 KB |
Output is correct |
13 |
Correct |
11 ms |
4308 KB |
Output is correct |
14 |
Correct |
11 ms |
4340 KB |
Output is correct |
15 |
Correct |
13 ms |
4364 KB |
Output is correct |
16 |
Correct |
14 ms |
4308 KB |
Output is correct |
17 |
Correct |
9 ms |
4308 KB |
Output is correct |
18 |
Correct |
10 ms |
4308 KB |
Output is correct |
19 |
Correct |
11 ms |
4308 KB |
Output is correct |
20 |
Correct |
13 ms |
4352 KB |
Output is correct |
21 |
Correct |
24 ms |
4476 KB |
Output is correct |
22 |
Correct |
30 ms |
4496 KB |
Output is correct |
23 |
Correct |
19 ms |
4436 KB |
Output is correct |
24 |
Correct |
34 ms |
4696 KB |
Output is correct |
25 |
Correct |
33 ms |
4700 KB |
Output is correct |
26 |
Correct |
35 ms |
4760 KB |
Output is correct |
27 |
Correct |
34 ms |
4692 KB |
Output is correct |
28 |
Correct |
34 ms |
4772 KB |
Output is correct |
29 |
Correct |
34 ms |
4692 KB |
Output is correct |
30 |
Correct |
37 ms |
4684 KB |
Output is correct |
31 |
Correct |
35 ms |
4788 KB |
Output is correct |
32 |
Correct |
39 ms |
4788 KB |
Output is correct |
33 |
Correct |
34 ms |
4636 KB |
Output is correct |
34 |
Correct |
33 ms |
4728 KB |
Output is correct |
35 |
Correct |
34 ms |
4756 KB |
Output is correct |
36 |
Correct |
36 ms |
4660 KB |
Output is correct |
37 |
Correct |
74 ms |
5732 KB |
Output is correct |
38 |
Correct |
76 ms |
5724 KB |
Output is correct |
39 |
Correct |
81 ms |
6988 KB |
Output is correct |
40 |
Correct |
107 ms |
6628 KB |
Output is correct |
41 |
Correct |
88 ms |
7700 KB |
Output is correct |
42 |
Correct |
100 ms |
6428 KB |
Output is correct |
43 |
Correct |
117 ms |
7316 KB |
Output is correct |
44 |
Correct |
107 ms |
7332 KB |
Output is correct |
45 |
Correct |
117 ms |
7376 KB |
Output is correct |
46 |
Correct |
89 ms |
6260 KB |
Output is correct |
47 |
Correct |
98 ms |
6452 KB |
Output is correct |
48 |
Correct |
106 ms |
7384 KB |
Output is correct |
49 |
Correct |
90 ms |
7140 KB |
Output is correct |
50 |
Correct |
102 ms |
6808 KB |
Output is correct |
51 |
Correct |
28 ms |
2260 KB |
Output is correct |
52 |
Correct |
123 ms |
8084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
4180 KB |
Output is correct |
2 |
Correct |
4 ms |
4180 KB |
Output is correct |
3 |
Correct |
2 ms |
2260 KB |
Output is correct |
4 |
Correct |
4 ms |
4264 KB |
Output is correct |
5 |
Correct |
6 ms |
4252 KB |
Output is correct |
6 |
Correct |
5 ms |
4180 KB |
Output is correct |
7 |
Correct |
4 ms |
4180 KB |
Output is correct |
8 |
Correct |
6 ms |
4180 KB |
Output is correct |
9 |
Correct |
6 ms |
4180 KB |
Output is correct |
10 |
Correct |
12 ms |
4308 KB |
Output is correct |
11 |
Correct |
13 ms |
4308 KB |
Output is correct |
12 |
Correct |
13 ms |
4308 KB |
Output is correct |
13 |
Correct |
11 ms |
4308 KB |
Output is correct |
14 |
Correct |
11 ms |
4340 KB |
Output is correct |
15 |
Correct |
13 ms |
4364 KB |
Output is correct |
16 |
Correct |
14 ms |
4308 KB |
Output is correct |
17 |
Correct |
9 ms |
4308 KB |
Output is correct |
18 |
Correct |
10 ms |
4308 KB |
Output is correct |
19 |
Correct |
11 ms |
4308 KB |
Output is correct |
20 |
Correct |
13 ms |
4352 KB |
Output is correct |
21 |
Correct |
24 ms |
4476 KB |
Output is correct |
22 |
Correct |
30 ms |
4496 KB |
Output is correct |
23 |
Correct |
19 ms |
4436 KB |
Output is correct |
24 |
Correct |
34 ms |
4696 KB |
Output is correct |
25 |
Correct |
33 ms |
4700 KB |
Output is correct |
26 |
Correct |
35 ms |
4760 KB |
Output is correct |
27 |
Correct |
34 ms |
4692 KB |
Output is correct |
28 |
Correct |
34 ms |
4772 KB |
Output is correct |
29 |
Correct |
34 ms |
4692 KB |
Output is correct |
30 |
Correct |
37 ms |
4684 KB |
Output is correct |
31 |
Correct |
35 ms |
4788 KB |
Output is correct |
32 |
Correct |
39 ms |
4788 KB |
Output is correct |
33 |
Correct |
34 ms |
4636 KB |
Output is correct |
34 |
Correct |
33 ms |
4728 KB |
Output is correct |
35 |
Correct |
34 ms |
4756 KB |
Output is correct |
36 |
Correct |
36 ms |
4660 KB |
Output is correct |
37 |
Correct |
74 ms |
5732 KB |
Output is correct |
38 |
Correct |
76 ms |
5724 KB |
Output is correct |
39 |
Correct |
81 ms |
6988 KB |
Output is correct |
40 |
Correct |
107 ms |
6628 KB |
Output is correct |
41 |
Correct |
88 ms |
7700 KB |
Output is correct |
42 |
Correct |
100 ms |
6428 KB |
Output is correct |
43 |
Correct |
117 ms |
7316 KB |
Output is correct |
44 |
Correct |
107 ms |
7332 KB |
Output is correct |
45 |
Correct |
117 ms |
7376 KB |
Output is correct |
46 |
Correct |
89 ms |
6260 KB |
Output is correct |
47 |
Correct |
98 ms |
6452 KB |
Output is correct |
48 |
Correct |
106 ms |
7384 KB |
Output is correct |
49 |
Correct |
90 ms |
7140 KB |
Output is correct |
50 |
Correct |
102 ms |
6808 KB |
Output is correct |
51 |
Correct |
28 ms |
2260 KB |
Output is correct |
52 |
Correct |
123 ms |
8084 KB |
Output is correct |
53 |
Correct |
124 ms |
7552 KB |
Output is correct |
54 |
Correct |
154 ms |
8528 KB |
Output is correct |
55 |
Correct |
184 ms |
11096 KB |
Output is correct |
56 |
Correct |
143 ms |
8056 KB |
Output is correct |
57 |
Correct |
213 ms |
11480 KB |
Output is correct |
58 |
Correct |
162 ms |
8712 KB |
Output is correct |
59 |
Correct |
174 ms |
9448 KB |
Output is correct |
60 |
Correct |
39 ms |
2260 KB |
Output is correct |
61 |
Correct |
183 ms |
9960 KB |
Output is correct |
62 |
Correct |
177 ms |
10156 KB |
Output is correct |
63 |
Correct |
169 ms |
10340 KB |
Output is correct |
64 |
Correct |
173 ms |
10172 KB |
Output is correct |
65 |
Correct |
101 ms |
7392 KB |
Output is correct |
66 |
Correct |
108 ms |
7656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
4180 KB |
Output is correct |
2 |
Correct |
4 ms |
4180 KB |
Output is correct |
3 |
Correct |
2 ms |
2260 KB |
Output is correct |
4 |
Correct |
4 ms |
4264 KB |
Output is correct |
5 |
Correct |
6 ms |
4252 KB |
Output is correct |
6 |
Correct |
5 ms |
4180 KB |
Output is correct |
7 |
Correct |
4 ms |
4180 KB |
Output is correct |
8 |
Correct |
6 ms |
4180 KB |
Output is correct |
9 |
Correct |
6 ms |
4180 KB |
Output is correct |
10 |
Correct |
12 ms |
4308 KB |
Output is correct |
11 |
Correct |
13 ms |
4308 KB |
Output is correct |
12 |
Correct |
13 ms |
4308 KB |
Output is correct |
13 |
Correct |
11 ms |
4308 KB |
Output is correct |
14 |
Correct |
11 ms |
4340 KB |
Output is correct |
15 |
Correct |
13 ms |
4364 KB |
Output is correct |
16 |
Correct |
14 ms |
4308 KB |
Output is correct |
17 |
Correct |
9 ms |
4308 KB |
Output is correct |
18 |
Correct |
10 ms |
4308 KB |
Output is correct |
19 |
Correct |
11 ms |
4308 KB |
Output is correct |
20 |
Correct |
13 ms |
4352 KB |
Output is correct |
21 |
Correct |
24 ms |
4476 KB |
Output is correct |
22 |
Correct |
30 ms |
4496 KB |
Output is correct |
23 |
Correct |
19 ms |
4436 KB |
Output is correct |
24 |
Correct |
34 ms |
4696 KB |
Output is correct |
25 |
Correct |
33 ms |
4700 KB |
Output is correct |
26 |
Correct |
35 ms |
4760 KB |
Output is correct |
27 |
Correct |
34 ms |
4692 KB |
Output is correct |
28 |
Correct |
34 ms |
4772 KB |
Output is correct |
29 |
Correct |
34 ms |
4692 KB |
Output is correct |
30 |
Correct |
37 ms |
4684 KB |
Output is correct |
31 |
Correct |
35 ms |
4788 KB |
Output is correct |
32 |
Correct |
39 ms |
4788 KB |
Output is correct |
33 |
Correct |
34 ms |
4636 KB |
Output is correct |
34 |
Correct |
33 ms |
4728 KB |
Output is correct |
35 |
Correct |
34 ms |
4756 KB |
Output is correct |
36 |
Correct |
36 ms |
4660 KB |
Output is correct |
37 |
Correct |
74 ms |
5732 KB |
Output is correct |
38 |
Correct |
76 ms |
5724 KB |
Output is correct |
39 |
Correct |
81 ms |
6988 KB |
Output is correct |
40 |
Correct |
107 ms |
6628 KB |
Output is correct |
41 |
Correct |
88 ms |
7700 KB |
Output is correct |
42 |
Correct |
100 ms |
6428 KB |
Output is correct |
43 |
Correct |
117 ms |
7316 KB |
Output is correct |
44 |
Correct |
107 ms |
7332 KB |
Output is correct |
45 |
Correct |
117 ms |
7376 KB |
Output is correct |
46 |
Correct |
89 ms |
6260 KB |
Output is correct |
47 |
Correct |
98 ms |
6452 KB |
Output is correct |
48 |
Correct |
106 ms |
7384 KB |
Output is correct |
49 |
Correct |
90 ms |
7140 KB |
Output is correct |
50 |
Correct |
102 ms |
6808 KB |
Output is correct |
51 |
Correct |
28 ms |
2260 KB |
Output is correct |
52 |
Correct |
123 ms |
8084 KB |
Output is correct |
53 |
Correct |
124 ms |
7552 KB |
Output is correct |
54 |
Correct |
154 ms |
8528 KB |
Output is correct |
55 |
Correct |
184 ms |
11096 KB |
Output is correct |
56 |
Correct |
143 ms |
8056 KB |
Output is correct |
57 |
Correct |
213 ms |
11480 KB |
Output is correct |
58 |
Correct |
162 ms |
8712 KB |
Output is correct |
59 |
Correct |
174 ms |
9448 KB |
Output is correct |
60 |
Correct |
39 ms |
2260 KB |
Output is correct |
61 |
Correct |
183 ms |
9960 KB |
Output is correct |
62 |
Correct |
177 ms |
10156 KB |
Output is correct |
63 |
Correct |
169 ms |
10340 KB |
Output is correct |
64 |
Correct |
173 ms |
10172 KB |
Output is correct |
65 |
Correct |
101 ms |
7392 KB |
Output is correct |
66 |
Correct |
108 ms |
7656 KB |
Output is correct |
67 |
Correct |
195 ms |
10432 KB |
Output is correct |
68 |
Correct |
55 ms |
2260 KB |
Output is correct |
69 |
Correct |
373 ms |
20708 KB |
Output is correct |
70 |
Correct |
300 ms |
15052 KB |
Output is correct |
71 |
Correct |
294 ms |
14728 KB |
Output is correct |
72 |
Correct |
237 ms |
13800 KB |
Output is correct |
73 |
Correct |
235 ms |
13784 KB |
Output is correct |
74 |
Correct |
400 ms |
21092 KB |
Output is correct |
75 |
Correct |
348 ms |
18096 KB |
Output is correct |
76 |
Correct |
398 ms |
21088 KB |
Output is correct |
77 |
Correct |
410 ms |
21188 KB |
Output is correct |