/* Author : Mychecksdead */
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
const int N = 510, M = 500, MX = 500*500/2 + 1;
int n, a[N], S = 0;
bitset<N*N/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;
}
for(int i = 0; i <= n; ++i){
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 <= M * M; x += 2){
ok = 1;
a[0] = x;
for(int i = 0; i <= n; ++i){
bool state1 = 0, state2 = 0;
if(i == 0){
int req = (S + x - a[i]) >> 1;
state1 = (req < MX && dp[i][req]);
}else{
int req = (S + x - a[i]) >> 1, req1 = ((S + x - a[i]) >> 1) - x;
state1 = (req < MX && dp[i][req]);
state2 = (req1 >= 0 && req1 < MX && 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 |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
6 ms |
852 KB |
Output is correct |
11 |
Correct |
5 ms |
740 KB |
Output is correct |
12 |
Correct |
5 ms |
852 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
4 ms |
724 KB |
Output is correct |
15 |
Correct |
4 ms |
740 KB |
Output is correct |
16 |
Correct |
5 ms |
852 KB |
Output is correct |
17 |
Correct |
3 ms |
596 KB |
Output is correct |
18 |
Correct |
4 ms |
724 KB |
Output is correct |
19 |
Correct |
4 ms |
724 KB |
Output is correct |
20 |
Correct |
5 ms |
852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
6 ms |
852 KB |
Output is correct |
11 |
Correct |
5 ms |
740 KB |
Output is correct |
12 |
Correct |
5 ms |
852 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
4 ms |
724 KB |
Output is correct |
15 |
Correct |
4 ms |
740 KB |
Output is correct |
16 |
Correct |
5 ms |
852 KB |
Output is correct |
17 |
Correct |
3 ms |
596 KB |
Output is correct |
18 |
Correct |
4 ms |
724 KB |
Output is correct |
19 |
Correct |
4 ms |
724 KB |
Output is correct |
20 |
Correct |
5 ms |
852 KB |
Output is correct |
21 |
Correct |
19 ms |
1296 KB |
Output is correct |
22 |
Correct |
25 ms |
1544 KB |
Output is correct |
23 |
Correct |
12 ms |
1108 KB |
Output is correct |
24 |
Correct |
41 ms |
1832 KB |
Output is correct |
25 |
Correct |
39 ms |
1872 KB |
Output is correct |
26 |
Correct |
45 ms |
1996 KB |
Output is correct |
27 |
Correct |
47 ms |
1948 KB |
Output is correct |
28 |
Correct |
44 ms |
1868 KB |
Output is correct |
29 |
Correct |
44 ms |
1852 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
45 ms |
2004 KB |
Output is correct |
32 |
Correct |
44 ms |
1992 KB |
Output is correct |
33 |
Correct |
44 ms |
1868 KB |
Output is correct |
34 |
Correct |
43 ms |
1868 KB |
Output is correct |
35 |
Correct |
44 ms |
1848 KB |
Output is correct |
36 |
Correct |
44 ms |
1976 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
6 ms |
852 KB |
Output is correct |
11 |
Correct |
5 ms |
740 KB |
Output is correct |
12 |
Correct |
5 ms |
852 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
4 ms |
724 KB |
Output is correct |
15 |
Correct |
4 ms |
740 KB |
Output is correct |
16 |
Correct |
5 ms |
852 KB |
Output is correct |
17 |
Correct |
3 ms |
596 KB |
Output is correct |
18 |
Correct |
4 ms |
724 KB |
Output is correct |
19 |
Correct |
4 ms |
724 KB |
Output is correct |
20 |
Correct |
5 ms |
852 KB |
Output is correct |
21 |
Correct |
19 ms |
1296 KB |
Output is correct |
22 |
Correct |
25 ms |
1544 KB |
Output is correct |
23 |
Correct |
12 ms |
1108 KB |
Output is correct |
24 |
Correct |
41 ms |
1832 KB |
Output is correct |
25 |
Correct |
39 ms |
1872 KB |
Output is correct |
26 |
Correct |
45 ms |
1996 KB |
Output is correct |
27 |
Correct |
47 ms |
1948 KB |
Output is correct |
28 |
Correct |
44 ms |
1868 KB |
Output is correct |
29 |
Correct |
44 ms |
1852 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
45 ms |
2004 KB |
Output is correct |
32 |
Correct |
44 ms |
1992 KB |
Output is correct |
33 |
Correct |
44 ms |
1868 KB |
Output is correct |
34 |
Correct |
43 ms |
1868 KB |
Output is correct |
35 |
Correct |
44 ms |
1848 KB |
Output is correct |
36 |
Correct |
44 ms |
1976 KB |
Output is correct |
37 |
Correct |
171 ms |
3572 KB |
Output is correct |
38 |
Correct |
182 ms |
3676 KB |
Output is correct |
39 |
Correct |
264 ms |
4364 KB |
Output is correct |
40 |
Correct |
320 ms |
4876 KB |
Output is correct |
41 |
Correct |
300 ms |
4620 KB |
Output is correct |
42 |
Correct |
273 ms |
4436 KB |
Output is correct |
43 |
Correct |
267 ms |
4676 KB |
Output is correct |
44 |
Correct |
276 ms |
4684 KB |
Output is correct |
45 |
Correct |
276 ms |
4692 KB |
Output is correct |
46 |
Correct |
302 ms |
4608 KB |
Output is correct |
47 |
Correct |
272 ms |
4548 KB |
Output is correct |
48 |
Correct |
273 ms |
4596 KB |
Output is correct |
49 |
Correct |
262 ms |
4584 KB |
Output is correct |
50 |
Correct |
271 ms |
4432 KB |
Output is correct |
51 |
Correct |
1 ms |
340 KB |
Output is correct |
52 |
Correct |
328 ms |
5064 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
6 ms |
852 KB |
Output is correct |
11 |
Correct |
5 ms |
740 KB |
Output is correct |
12 |
Correct |
5 ms |
852 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
4 ms |
724 KB |
Output is correct |
15 |
Correct |
4 ms |
740 KB |
Output is correct |
16 |
Correct |
5 ms |
852 KB |
Output is correct |
17 |
Correct |
3 ms |
596 KB |
Output is correct |
18 |
Correct |
4 ms |
724 KB |
Output is correct |
19 |
Correct |
4 ms |
724 KB |
Output is correct |
20 |
Correct |
5 ms |
852 KB |
Output is correct |
21 |
Correct |
19 ms |
1296 KB |
Output is correct |
22 |
Correct |
25 ms |
1544 KB |
Output is correct |
23 |
Correct |
12 ms |
1108 KB |
Output is correct |
24 |
Correct |
41 ms |
1832 KB |
Output is correct |
25 |
Correct |
39 ms |
1872 KB |
Output is correct |
26 |
Correct |
45 ms |
1996 KB |
Output is correct |
27 |
Correct |
47 ms |
1948 KB |
Output is correct |
28 |
Correct |
44 ms |
1868 KB |
Output is correct |
29 |
Correct |
44 ms |
1852 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
45 ms |
2004 KB |
Output is correct |
32 |
Correct |
44 ms |
1992 KB |
Output is correct |
33 |
Correct |
44 ms |
1868 KB |
Output is correct |
34 |
Correct |
43 ms |
1868 KB |
Output is correct |
35 |
Correct |
44 ms |
1848 KB |
Output is correct |
36 |
Correct |
44 ms |
1976 KB |
Output is correct |
37 |
Correct |
171 ms |
3572 KB |
Output is correct |
38 |
Correct |
182 ms |
3676 KB |
Output is correct |
39 |
Correct |
264 ms |
4364 KB |
Output is correct |
40 |
Correct |
320 ms |
4876 KB |
Output is correct |
41 |
Correct |
300 ms |
4620 KB |
Output is correct |
42 |
Correct |
273 ms |
4436 KB |
Output is correct |
43 |
Correct |
267 ms |
4676 KB |
Output is correct |
44 |
Correct |
276 ms |
4684 KB |
Output is correct |
45 |
Correct |
276 ms |
4692 KB |
Output is correct |
46 |
Correct |
302 ms |
4608 KB |
Output is correct |
47 |
Correct |
272 ms |
4548 KB |
Output is correct |
48 |
Correct |
273 ms |
4596 KB |
Output is correct |
49 |
Correct |
262 ms |
4584 KB |
Output is correct |
50 |
Correct |
271 ms |
4432 KB |
Output is correct |
51 |
Correct |
1 ms |
340 KB |
Output is correct |
52 |
Correct |
328 ms |
5064 KB |
Output is correct |
53 |
Correct |
394 ms |
5436 KB |
Output is correct |
54 |
Correct |
546 ms |
6452 KB |
Output is correct |
55 |
Correct |
550 ms |
6608 KB |
Output is correct |
56 |
Correct |
419 ms |
5580 KB |
Output is correct |
57 |
Correct |
564 ms |
6600 KB |
Output is correct |
58 |
Correct |
529 ms |
6360 KB |
Output is correct |
59 |
Correct |
544 ms |
6484 KB |
Output is correct |
60 |
Correct |
1 ms |
340 KB |
Output is correct |
61 |
Correct |
552 ms |
6492 KB |
Output is correct |
62 |
Correct |
460 ms |
6024 KB |
Output is correct |
63 |
Correct |
471 ms |
5964 KB |
Output is correct |
64 |
Correct |
450 ms |
5856 KB |
Output is correct |
65 |
Correct |
418 ms |
5468 KB |
Output is correct |
66 |
Correct |
398 ms |
5352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
6 ms |
852 KB |
Output is correct |
11 |
Correct |
5 ms |
740 KB |
Output is correct |
12 |
Correct |
5 ms |
852 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
4 ms |
724 KB |
Output is correct |
15 |
Correct |
4 ms |
740 KB |
Output is correct |
16 |
Correct |
5 ms |
852 KB |
Output is correct |
17 |
Correct |
3 ms |
596 KB |
Output is correct |
18 |
Correct |
4 ms |
724 KB |
Output is correct |
19 |
Correct |
4 ms |
724 KB |
Output is correct |
20 |
Correct |
5 ms |
852 KB |
Output is correct |
21 |
Correct |
19 ms |
1296 KB |
Output is correct |
22 |
Correct |
25 ms |
1544 KB |
Output is correct |
23 |
Correct |
12 ms |
1108 KB |
Output is correct |
24 |
Correct |
41 ms |
1832 KB |
Output is correct |
25 |
Correct |
39 ms |
1872 KB |
Output is correct |
26 |
Correct |
45 ms |
1996 KB |
Output is correct |
27 |
Correct |
47 ms |
1948 KB |
Output is correct |
28 |
Correct |
44 ms |
1868 KB |
Output is correct |
29 |
Correct |
44 ms |
1852 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
45 ms |
2004 KB |
Output is correct |
32 |
Correct |
44 ms |
1992 KB |
Output is correct |
33 |
Correct |
44 ms |
1868 KB |
Output is correct |
34 |
Correct |
43 ms |
1868 KB |
Output is correct |
35 |
Correct |
44 ms |
1848 KB |
Output is correct |
36 |
Correct |
44 ms |
1976 KB |
Output is correct |
37 |
Correct |
171 ms |
3572 KB |
Output is correct |
38 |
Correct |
182 ms |
3676 KB |
Output is correct |
39 |
Correct |
264 ms |
4364 KB |
Output is correct |
40 |
Correct |
320 ms |
4876 KB |
Output is correct |
41 |
Correct |
300 ms |
4620 KB |
Output is correct |
42 |
Correct |
273 ms |
4436 KB |
Output is correct |
43 |
Correct |
267 ms |
4676 KB |
Output is correct |
44 |
Correct |
276 ms |
4684 KB |
Output is correct |
45 |
Correct |
276 ms |
4692 KB |
Output is correct |
46 |
Correct |
302 ms |
4608 KB |
Output is correct |
47 |
Correct |
272 ms |
4548 KB |
Output is correct |
48 |
Correct |
273 ms |
4596 KB |
Output is correct |
49 |
Correct |
262 ms |
4584 KB |
Output is correct |
50 |
Correct |
271 ms |
4432 KB |
Output is correct |
51 |
Correct |
1 ms |
340 KB |
Output is correct |
52 |
Correct |
328 ms |
5064 KB |
Output is correct |
53 |
Correct |
394 ms |
5436 KB |
Output is correct |
54 |
Correct |
546 ms |
6452 KB |
Output is correct |
55 |
Correct |
550 ms |
6608 KB |
Output is correct |
56 |
Correct |
419 ms |
5580 KB |
Output is correct |
57 |
Correct |
564 ms |
6600 KB |
Output is correct |
58 |
Correct |
529 ms |
6360 KB |
Output is correct |
59 |
Correct |
544 ms |
6484 KB |
Output is correct |
60 |
Correct |
1 ms |
340 KB |
Output is correct |
61 |
Correct |
552 ms |
6492 KB |
Output is correct |
62 |
Correct |
460 ms |
6024 KB |
Output is correct |
63 |
Correct |
471 ms |
5964 KB |
Output is correct |
64 |
Correct |
450 ms |
5856 KB |
Output is correct |
65 |
Correct |
418 ms |
5468 KB |
Output is correct |
66 |
Correct |
398 ms |
5352 KB |
Output is correct |
67 |
Correct |
706 ms |
7244 KB |
Output is correct |
68 |
Execution timed out |
1018 ms |
8184 KB |
Time limit exceeded |
69 |
Halted |
0 ms |
0 KB |
- |