/* Author : Mychecksdead */
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
const int N = 510, M = 502, MX = 600*600 + 10;
int n, a[N], S = 0;
bitset<MX/2> dp[N];
void solve(){
cin >> n;
bool ok = 1;
for(int i = 1; i <= n; ++i){
cin >> a[i];
S += a[i];
if(a[i] % 2 != a[1] % 2){
ok = 0;
}
}
if(!ok || S % 2){
cout << 0;
return;
}
vector<int> used(M);
vector<int> s;
s.pb(0);
for(int i = 1; i <= n; ++i){
if(!used[a[i]]) s.pb(i);
used[a[i]] = 1;
}
for(int i: s){
dp[i][0] = 1;
for(int l = 1; l <= n; ++l){
if(i == l) continue;
dp[i] = dp[i] | (dp[i] << a[l]);
}
}
vector<int> possible;
for(int x = 2 - (a[1] % 2); x <= S; x += 2){
ok = 1;
a[0] = x;
for(int i: s){
bool state1 = 0, state2 = 0;
int req = -1, req1 = -1;
int c = S + x - a[i];
req = c >> 1;
if(req < MX){
if(req > S/2) req = c - req;
state1 = dp[i][req];
}
if(i > 0){
req1 = (c >> 1) - x;
if(req1 >= 0 && req1 < MX){
if(req1 > S/2) req1 = c - req1;
state2 = dp[i][req1];
}
}
if(!(state1 | state2)){
ok = 0;
break;
}
}
if(ok){
possible.pb(x);
}
}
cout << possible.size() << '\n';
for(int p: possible) cout << p << ' ';
}
int main(){
cin.tie(0); ios::sync_with_stdio(0);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
596 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
596 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
3 ms |
596 KB |
Output is correct |
12 |
Correct |
3 ms |
596 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
3 ms |
596 KB |
Output is correct |
15 |
Correct |
2 ms |
596 KB |
Output is correct |
16 |
Correct |
2 ms |
596 KB |
Output is correct |
17 |
Correct |
1 ms |
596 KB |
Output is correct |
18 |
Correct |
2 ms |
596 KB |
Output is correct |
19 |
Correct |
2 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
596 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
3 ms |
596 KB |
Output is correct |
12 |
Correct |
3 ms |
596 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
3 ms |
596 KB |
Output is correct |
15 |
Correct |
2 ms |
596 KB |
Output is correct |
16 |
Correct |
2 ms |
596 KB |
Output is correct |
17 |
Correct |
1 ms |
596 KB |
Output is correct |
18 |
Correct |
2 ms |
596 KB |
Output is correct |
19 |
Correct |
2 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
16 ms |
1108 KB |
Output is correct |
22 |
Correct |
21 ms |
1228 KB |
Output is correct |
23 |
Correct |
10 ms |
1068 KB |
Output is correct |
24 |
Correct |
27 ms |
1360 KB |
Output is correct |
25 |
Correct |
5 ms |
596 KB |
Output is correct |
26 |
Correct |
6 ms |
596 KB |
Output is correct |
27 |
Correct |
5 ms |
468 KB |
Output is correct |
28 |
Correct |
3 ms |
468 KB |
Output is correct |
29 |
Correct |
3 ms |
468 KB |
Output is correct |
30 |
Correct |
0 ms |
340 KB |
Output is correct |
31 |
Correct |
19 ms |
1016 KB |
Output is correct |
32 |
Correct |
34 ms |
1416 KB |
Output is correct |
33 |
Correct |
2 ms |
340 KB |
Output is correct |
34 |
Correct |
2 ms |
388 KB |
Output is correct |
35 |
Correct |
3 ms |
468 KB |
Output is correct |
36 |
Correct |
40 ms |
1520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
596 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
3 ms |
596 KB |
Output is correct |
12 |
Correct |
3 ms |
596 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
3 ms |
596 KB |
Output is correct |
15 |
Correct |
2 ms |
596 KB |
Output is correct |
16 |
Correct |
2 ms |
596 KB |
Output is correct |
17 |
Correct |
1 ms |
596 KB |
Output is correct |
18 |
Correct |
2 ms |
596 KB |
Output is correct |
19 |
Correct |
2 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
16 ms |
1108 KB |
Output is correct |
22 |
Correct |
21 ms |
1228 KB |
Output is correct |
23 |
Correct |
10 ms |
1068 KB |
Output is correct |
24 |
Correct |
27 ms |
1360 KB |
Output is correct |
25 |
Correct |
5 ms |
596 KB |
Output is correct |
26 |
Correct |
6 ms |
596 KB |
Output is correct |
27 |
Correct |
5 ms |
468 KB |
Output is correct |
28 |
Correct |
3 ms |
468 KB |
Output is correct |
29 |
Correct |
3 ms |
468 KB |
Output is correct |
30 |
Correct |
0 ms |
340 KB |
Output is correct |
31 |
Correct |
19 ms |
1016 KB |
Output is correct |
32 |
Correct |
34 ms |
1416 KB |
Output is correct |
33 |
Correct |
2 ms |
340 KB |
Output is correct |
34 |
Correct |
2 ms |
388 KB |
Output is correct |
35 |
Correct |
3 ms |
468 KB |
Output is correct |
36 |
Correct |
40 ms |
1520 KB |
Output is correct |
37 |
Correct |
68 ms |
1604 KB |
Output is correct |
38 |
Correct |
75 ms |
1724 KB |
Output is correct |
39 |
Correct |
4 ms |
340 KB |
Output is correct |
40 |
Correct |
264 ms |
3808 KB |
Output is correct |
41 |
Correct |
4 ms |
340 KB |
Output is correct |
42 |
Correct |
197 ms |
3212 KB |
Output is correct |
43 |
Correct |
47 ms |
1256 KB |
Output is correct |
44 |
Correct |
48 ms |
1304 KB |
Output is correct |
45 |
Correct |
50 ms |
1256 KB |
Output is correct |
46 |
Correct |
242 ms |
3664 KB |
Output is correct |
47 |
Correct |
188 ms |
3096 KB |
Output is correct |
48 |
Correct |
12 ms |
724 KB |
Output is correct |
49 |
Correct |
8 ms |
468 KB |
Output is correct |
50 |
Correct |
215 ms |
3516 KB |
Output is correct |
51 |
Correct |
0 ms |
340 KB |
Output is correct |
52 |
Correct |
32 ms |
1088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
596 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
3 ms |
596 KB |
Output is correct |
12 |
Correct |
3 ms |
596 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
3 ms |
596 KB |
Output is correct |
15 |
Correct |
2 ms |
596 KB |
Output is correct |
16 |
Correct |
2 ms |
596 KB |
Output is correct |
17 |
Correct |
1 ms |
596 KB |
Output is correct |
18 |
Correct |
2 ms |
596 KB |
Output is correct |
19 |
Correct |
2 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
16 ms |
1108 KB |
Output is correct |
22 |
Correct |
21 ms |
1228 KB |
Output is correct |
23 |
Correct |
10 ms |
1068 KB |
Output is correct |
24 |
Correct |
27 ms |
1360 KB |
Output is correct |
25 |
Correct |
5 ms |
596 KB |
Output is correct |
26 |
Correct |
6 ms |
596 KB |
Output is correct |
27 |
Correct |
5 ms |
468 KB |
Output is correct |
28 |
Correct |
3 ms |
468 KB |
Output is correct |
29 |
Correct |
3 ms |
468 KB |
Output is correct |
30 |
Correct |
0 ms |
340 KB |
Output is correct |
31 |
Correct |
19 ms |
1016 KB |
Output is correct |
32 |
Correct |
34 ms |
1416 KB |
Output is correct |
33 |
Correct |
2 ms |
340 KB |
Output is correct |
34 |
Correct |
2 ms |
388 KB |
Output is correct |
35 |
Correct |
3 ms |
468 KB |
Output is correct |
36 |
Correct |
40 ms |
1520 KB |
Output is correct |
37 |
Correct |
68 ms |
1604 KB |
Output is correct |
38 |
Correct |
75 ms |
1724 KB |
Output is correct |
39 |
Correct |
4 ms |
340 KB |
Output is correct |
40 |
Correct |
264 ms |
3808 KB |
Output is correct |
41 |
Correct |
4 ms |
340 KB |
Output is correct |
42 |
Correct |
197 ms |
3212 KB |
Output is correct |
43 |
Correct |
47 ms |
1256 KB |
Output is correct |
44 |
Correct |
48 ms |
1304 KB |
Output is correct |
45 |
Correct |
50 ms |
1256 KB |
Output is correct |
46 |
Correct |
242 ms |
3664 KB |
Output is correct |
47 |
Correct |
188 ms |
3096 KB |
Output is correct |
48 |
Correct |
12 ms |
724 KB |
Output is correct |
49 |
Correct |
8 ms |
468 KB |
Output is correct |
50 |
Correct |
215 ms |
3516 KB |
Output is correct |
51 |
Correct |
0 ms |
340 KB |
Output is correct |
52 |
Correct |
32 ms |
1088 KB |
Output is correct |
53 |
Correct |
246 ms |
3424 KB |
Output is correct |
54 |
Correct |
288 ms |
3504 KB |
Output is correct |
55 |
Correct |
43 ms |
1232 KB |
Output is correct |
56 |
Correct |
309 ms |
3864 KB |
Output is correct |
57 |
Correct |
46 ms |
1356 KB |
Output is correct |
58 |
Correct |
430 ms |
4976 KB |
Output is correct |
59 |
Correct |
245 ms |
3164 KB |
Output is correct |
60 |
Correct |
0 ms |
340 KB |
Output is correct |
61 |
Correct |
245 ms |
3288 KB |
Output is correct |
62 |
Correct |
125 ms |
2124 KB |
Output is correct |
63 |
Correct |
67 ms |
1584 KB |
Output is correct |
64 |
Correct |
65 ms |
1484 KB |
Output is correct |
65 |
Correct |
19 ms |
596 KB |
Output is correct |
66 |
Correct |
74 ms |
1240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
596 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
3 ms |
596 KB |
Output is correct |
12 |
Correct |
3 ms |
596 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
3 ms |
596 KB |
Output is correct |
15 |
Correct |
2 ms |
596 KB |
Output is correct |
16 |
Correct |
2 ms |
596 KB |
Output is correct |
17 |
Correct |
1 ms |
596 KB |
Output is correct |
18 |
Correct |
2 ms |
596 KB |
Output is correct |
19 |
Correct |
2 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
16 ms |
1108 KB |
Output is correct |
22 |
Correct |
21 ms |
1228 KB |
Output is correct |
23 |
Correct |
10 ms |
1068 KB |
Output is correct |
24 |
Correct |
27 ms |
1360 KB |
Output is correct |
25 |
Correct |
5 ms |
596 KB |
Output is correct |
26 |
Correct |
6 ms |
596 KB |
Output is correct |
27 |
Correct |
5 ms |
468 KB |
Output is correct |
28 |
Correct |
3 ms |
468 KB |
Output is correct |
29 |
Correct |
3 ms |
468 KB |
Output is correct |
30 |
Correct |
0 ms |
340 KB |
Output is correct |
31 |
Correct |
19 ms |
1016 KB |
Output is correct |
32 |
Correct |
34 ms |
1416 KB |
Output is correct |
33 |
Correct |
2 ms |
340 KB |
Output is correct |
34 |
Correct |
2 ms |
388 KB |
Output is correct |
35 |
Correct |
3 ms |
468 KB |
Output is correct |
36 |
Correct |
40 ms |
1520 KB |
Output is correct |
37 |
Correct |
68 ms |
1604 KB |
Output is correct |
38 |
Correct |
75 ms |
1724 KB |
Output is correct |
39 |
Correct |
4 ms |
340 KB |
Output is correct |
40 |
Correct |
264 ms |
3808 KB |
Output is correct |
41 |
Correct |
4 ms |
340 KB |
Output is correct |
42 |
Correct |
197 ms |
3212 KB |
Output is correct |
43 |
Correct |
47 ms |
1256 KB |
Output is correct |
44 |
Correct |
48 ms |
1304 KB |
Output is correct |
45 |
Correct |
50 ms |
1256 KB |
Output is correct |
46 |
Correct |
242 ms |
3664 KB |
Output is correct |
47 |
Correct |
188 ms |
3096 KB |
Output is correct |
48 |
Correct |
12 ms |
724 KB |
Output is correct |
49 |
Correct |
8 ms |
468 KB |
Output is correct |
50 |
Correct |
215 ms |
3516 KB |
Output is correct |
51 |
Correct |
0 ms |
340 KB |
Output is correct |
52 |
Correct |
32 ms |
1088 KB |
Output is correct |
53 |
Correct |
246 ms |
3424 KB |
Output is correct |
54 |
Correct |
288 ms |
3504 KB |
Output is correct |
55 |
Correct |
43 ms |
1232 KB |
Output is correct |
56 |
Correct |
309 ms |
3864 KB |
Output is correct |
57 |
Correct |
46 ms |
1356 KB |
Output is correct |
58 |
Correct |
430 ms |
4976 KB |
Output is correct |
59 |
Correct |
245 ms |
3164 KB |
Output is correct |
60 |
Correct |
0 ms |
340 KB |
Output is correct |
61 |
Correct |
245 ms |
3288 KB |
Output is correct |
62 |
Correct |
125 ms |
2124 KB |
Output is correct |
63 |
Correct |
67 ms |
1584 KB |
Output is correct |
64 |
Correct |
65 ms |
1484 KB |
Output is correct |
65 |
Correct |
19 ms |
596 KB |
Output is correct |
66 |
Correct |
74 ms |
1240 KB |
Output is correct |
67 |
Correct |
568 ms |
6176 KB |
Output is correct |
68 |
Correct |
820 ms |
6484 KB |
Output is correct |
69 |
Incorrect |
111 ms |
2140 KB |
Output isn't correct |
70 |
Halted |
0 ms |
0 KB |
- |