#include <bits/stdc++.h>
using namespace std;
const int NM = 500, MOD = 1e9+321;
int N, a[NM+5], sum = 0, dp[NM*NM+5], dp0[NM*NM+5], K = 0;
bool ok[NM*NM+5];
void add(int x){
for (int i = NM*NM; i >= x; i--)
dp[i] = (dp[i]+dp[i-x])%MOD;
}
void remove(int x){
for (int i = x; i <= NM*NM; i++)
dp[i] = (dp[i]+MOD-dp[i-x])%MOD;
}
void solve(int t){
for (int i = 0; i <= NM*NM; i++) dp[i] = dp0[i];
remove(a[t]);
for (int i = 1; i <= NM*NM; i++)
if ((sum-a[t]+i)%2 != 0 || (sum-a[t]+i)/2-i < 0 || !dp[(sum-a[t]+i)/2-i]) ok[i] = 0;
}
int 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];
sum += a[i];
add(a[i]);
}
if (sum%2 != 0 || !dp[sum/2]){
cout << "0\n";
return 0;
}
for (int i = 0; i <= NM*NM; i++){
dp0[i] = dp[i];
ok[i] = 1;
}
for (int i = 1; i <= N; i++)
solve(i);
for (int i = 1; i <= NM*NM; i++) K += ok[i];
cout << K << '\n';
for (int i = 1; i <= NM*NM; i++)
if (ok[i]) cout << i << ' ';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
2652 KB |
Output is correct |
2 |
Correct |
8 ms |
2652 KB |
Output is correct |
3 |
Correct |
2 ms |
1372 KB |
Output is correct |
4 |
Correct |
6 ms |
2652 KB |
Output is correct |
5 |
Correct |
14 ms |
2512 KB |
Output is correct |
6 |
Correct |
10 ms |
2652 KB |
Output is correct |
7 |
Correct |
8 ms |
2652 KB |
Output is correct |
8 |
Correct |
16 ms |
2904 KB |
Output is correct |
9 |
Correct |
12 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
2652 KB |
Output is correct |
2 |
Correct |
8 ms |
2652 KB |
Output is correct |
3 |
Correct |
2 ms |
1372 KB |
Output is correct |
4 |
Correct |
6 ms |
2652 KB |
Output is correct |
5 |
Correct |
14 ms |
2512 KB |
Output is correct |
6 |
Correct |
10 ms |
2652 KB |
Output is correct |
7 |
Correct |
8 ms |
2652 KB |
Output is correct |
8 |
Correct |
16 ms |
2904 KB |
Output is correct |
9 |
Correct |
12 ms |
2652 KB |
Output is correct |
10 |
Correct |
29 ms |
2508 KB |
Output is correct |
11 |
Correct |
31 ms |
2652 KB |
Output is correct |
12 |
Correct |
37 ms |
2468 KB |
Output is correct |
13 |
Correct |
25 ms |
2652 KB |
Output is correct |
14 |
Correct |
26 ms |
2652 KB |
Output is correct |
15 |
Correct |
29 ms |
2652 KB |
Output is correct |
16 |
Correct |
33 ms |
2652 KB |
Output is correct |
17 |
Correct |
19 ms |
2652 KB |
Output is correct |
18 |
Correct |
23 ms |
2652 KB |
Output is correct |
19 |
Correct |
25 ms |
2652 KB |
Output is correct |
20 |
Correct |
26 ms |
2472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
2652 KB |
Output is correct |
2 |
Correct |
8 ms |
2652 KB |
Output is correct |
3 |
Correct |
2 ms |
1372 KB |
Output is correct |
4 |
Correct |
6 ms |
2652 KB |
Output is correct |
5 |
Correct |
14 ms |
2512 KB |
Output is correct |
6 |
Correct |
10 ms |
2652 KB |
Output is correct |
7 |
Correct |
8 ms |
2652 KB |
Output is correct |
8 |
Correct |
16 ms |
2904 KB |
Output is correct |
9 |
Correct |
12 ms |
2652 KB |
Output is correct |
10 |
Correct |
29 ms |
2508 KB |
Output is correct |
11 |
Correct |
31 ms |
2652 KB |
Output is correct |
12 |
Correct |
37 ms |
2468 KB |
Output is correct |
13 |
Correct |
25 ms |
2652 KB |
Output is correct |
14 |
Correct |
26 ms |
2652 KB |
Output is correct |
15 |
Correct |
29 ms |
2652 KB |
Output is correct |
16 |
Correct |
33 ms |
2652 KB |
Output is correct |
17 |
Correct |
19 ms |
2652 KB |
Output is correct |
18 |
Correct |
23 ms |
2652 KB |
Output is correct |
19 |
Correct |
25 ms |
2652 KB |
Output is correct |
20 |
Correct |
26 ms |
2472 KB |
Output is correct |
21 |
Correct |
57 ms |
2644 KB |
Output is correct |
22 |
Correct |
67 ms |
2652 KB |
Output is correct |
23 |
Correct |
56 ms |
2640 KB |
Output is correct |
24 |
Correct |
90 ms |
2632 KB |
Output is correct |
25 |
Correct |
95 ms |
2632 KB |
Output is correct |
26 |
Correct |
85 ms |
2652 KB |
Output is correct |
27 |
Correct |
93 ms |
2640 KB |
Output is correct |
28 |
Correct |
96 ms |
2640 KB |
Output is correct |
29 |
Correct |
87 ms |
2644 KB |
Output is correct |
30 |
Correct |
91 ms |
2388 KB |
Output is correct |
31 |
Correct |
101 ms |
2704 KB |
Output is correct |
32 |
Correct |
89 ms |
2644 KB |
Output is correct |
33 |
Correct |
87 ms |
2636 KB |
Output is correct |
34 |
Correct |
85 ms |
2632 KB |
Output is correct |
35 |
Correct |
97 ms |
2644 KB |
Output is correct |
36 |
Correct |
87 ms |
2632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
2652 KB |
Output is correct |
2 |
Correct |
8 ms |
2652 KB |
Output is correct |
3 |
Correct |
2 ms |
1372 KB |
Output is correct |
4 |
Correct |
6 ms |
2652 KB |
Output is correct |
5 |
Correct |
14 ms |
2512 KB |
Output is correct |
6 |
Correct |
10 ms |
2652 KB |
Output is correct |
7 |
Correct |
8 ms |
2652 KB |
Output is correct |
8 |
Correct |
16 ms |
2904 KB |
Output is correct |
9 |
Correct |
12 ms |
2652 KB |
Output is correct |
10 |
Correct |
29 ms |
2508 KB |
Output is correct |
11 |
Correct |
31 ms |
2652 KB |
Output is correct |
12 |
Correct |
37 ms |
2468 KB |
Output is correct |
13 |
Correct |
25 ms |
2652 KB |
Output is correct |
14 |
Correct |
26 ms |
2652 KB |
Output is correct |
15 |
Correct |
29 ms |
2652 KB |
Output is correct |
16 |
Correct |
33 ms |
2652 KB |
Output is correct |
17 |
Correct |
19 ms |
2652 KB |
Output is correct |
18 |
Correct |
23 ms |
2652 KB |
Output is correct |
19 |
Correct |
25 ms |
2652 KB |
Output is correct |
20 |
Correct |
26 ms |
2472 KB |
Output is correct |
21 |
Correct |
57 ms |
2644 KB |
Output is correct |
22 |
Correct |
67 ms |
2652 KB |
Output is correct |
23 |
Correct |
56 ms |
2640 KB |
Output is correct |
24 |
Correct |
90 ms |
2632 KB |
Output is correct |
25 |
Correct |
95 ms |
2632 KB |
Output is correct |
26 |
Correct |
85 ms |
2652 KB |
Output is correct |
27 |
Correct |
93 ms |
2640 KB |
Output is correct |
28 |
Correct |
96 ms |
2640 KB |
Output is correct |
29 |
Correct |
87 ms |
2644 KB |
Output is correct |
30 |
Correct |
91 ms |
2388 KB |
Output is correct |
31 |
Correct |
101 ms |
2704 KB |
Output is correct |
32 |
Correct |
89 ms |
2644 KB |
Output is correct |
33 |
Correct |
87 ms |
2636 KB |
Output is correct |
34 |
Correct |
85 ms |
2632 KB |
Output is correct |
35 |
Correct |
97 ms |
2644 KB |
Output is correct |
36 |
Correct |
87 ms |
2632 KB |
Output is correct |
37 |
Correct |
167 ms |
2460 KB |
Output is correct |
38 |
Correct |
174 ms |
2440 KB |
Output is correct |
39 |
Correct |
218 ms |
2644 KB |
Output is correct |
40 |
Correct |
225 ms |
2636 KB |
Output is correct |
41 |
Correct |
227 ms |
2464 KB |
Output is correct |
42 |
Correct |
217 ms |
2900 KB |
Output is correct |
43 |
Correct |
211 ms |
2644 KB |
Output is correct |
44 |
Correct |
235 ms |
2644 KB |
Output is correct |
45 |
Correct |
224 ms |
2644 KB |
Output is correct |
46 |
Correct |
232 ms |
2388 KB |
Output is correct |
47 |
Correct |
217 ms |
2636 KB |
Output is correct |
48 |
Correct |
216 ms |
2632 KB |
Output is correct |
49 |
Correct |
230 ms |
2644 KB |
Output is correct |
50 |
Correct |
215 ms |
2644 KB |
Output is correct |
51 |
Correct |
75 ms |
1420 KB |
Output is correct |
52 |
Correct |
241 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
2652 KB |
Output is correct |
2 |
Correct |
8 ms |
2652 KB |
Output is correct |
3 |
Correct |
2 ms |
1372 KB |
Output is correct |
4 |
Correct |
6 ms |
2652 KB |
Output is correct |
5 |
Correct |
14 ms |
2512 KB |
Output is correct |
6 |
Correct |
10 ms |
2652 KB |
Output is correct |
7 |
Correct |
8 ms |
2652 KB |
Output is correct |
8 |
Correct |
16 ms |
2904 KB |
Output is correct |
9 |
Correct |
12 ms |
2652 KB |
Output is correct |
10 |
Correct |
29 ms |
2508 KB |
Output is correct |
11 |
Correct |
31 ms |
2652 KB |
Output is correct |
12 |
Correct |
37 ms |
2468 KB |
Output is correct |
13 |
Correct |
25 ms |
2652 KB |
Output is correct |
14 |
Correct |
26 ms |
2652 KB |
Output is correct |
15 |
Correct |
29 ms |
2652 KB |
Output is correct |
16 |
Correct |
33 ms |
2652 KB |
Output is correct |
17 |
Correct |
19 ms |
2652 KB |
Output is correct |
18 |
Correct |
23 ms |
2652 KB |
Output is correct |
19 |
Correct |
25 ms |
2652 KB |
Output is correct |
20 |
Correct |
26 ms |
2472 KB |
Output is correct |
21 |
Correct |
57 ms |
2644 KB |
Output is correct |
22 |
Correct |
67 ms |
2652 KB |
Output is correct |
23 |
Correct |
56 ms |
2640 KB |
Output is correct |
24 |
Correct |
90 ms |
2632 KB |
Output is correct |
25 |
Correct |
95 ms |
2632 KB |
Output is correct |
26 |
Correct |
85 ms |
2652 KB |
Output is correct |
27 |
Correct |
93 ms |
2640 KB |
Output is correct |
28 |
Correct |
96 ms |
2640 KB |
Output is correct |
29 |
Correct |
87 ms |
2644 KB |
Output is correct |
30 |
Correct |
91 ms |
2388 KB |
Output is correct |
31 |
Correct |
101 ms |
2704 KB |
Output is correct |
32 |
Correct |
89 ms |
2644 KB |
Output is correct |
33 |
Correct |
87 ms |
2636 KB |
Output is correct |
34 |
Correct |
85 ms |
2632 KB |
Output is correct |
35 |
Correct |
97 ms |
2644 KB |
Output is correct |
36 |
Correct |
87 ms |
2632 KB |
Output is correct |
37 |
Correct |
167 ms |
2460 KB |
Output is correct |
38 |
Correct |
174 ms |
2440 KB |
Output is correct |
39 |
Correct |
218 ms |
2644 KB |
Output is correct |
40 |
Correct |
225 ms |
2636 KB |
Output is correct |
41 |
Correct |
227 ms |
2464 KB |
Output is correct |
42 |
Correct |
217 ms |
2900 KB |
Output is correct |
43 |
Correct |
211 ms |
2644 KB |
Output is correct |
44 |
Correct |
235 ms |
2644 KB |
Output is correct |
45 |
Correct |
224 ms |
2644 KB |
Output is correct |
46 |
Correct |
232 ms |
2388 KB |
Output is correct |
47 |
Correct |
217 ms |
2636 KB |
Output is correct |
48 |
Correct |
216 ms |
2632 KB |
Output is correct |
49 |
Correct |
230 ms |
2644 KB |
Output is correct |
50 |
Correct |
215 ms |
2644 KB |
Output is correct |
51 |
Correct |
75 ms |
1420 KB |
Output is correct |
52 |
Correct |
241 ms |
2644 KB |
Output is correct |
53 |
Correct |
260 ms |
2712 KB |
Output is correct |
54 |
Correct |
292 ms |
2636 KB |
Output is correct |
55 |
Correct |
315 ms |
2888 KB |
Output is correct |
56 |
Correct |
261 ms |
2648 KB |
Output is correct |
57 |
Correct |
316 ms |
2700 KB |
Output is correct |
58 |
Correct |
309 ms |
2644 KB |
Output is correct |
59 |
Correct |
305 ms |
2636 KB |
Output is correct |
60 |
Correct |
105 ms |
1416 KB |
Output is correct |
61 |
Correct |
347 ms |
2632 KB |
Output is correct |
62 |
Correct |
304 ms |
2900 KB |
Output is correct |
63 |
Correct |
278 ms |
2676 KB |
Output is correct |
64 |
Correct |
271 ms |
2900 KB |
Output is correct |
65 |
Correct |
280 ms |
2456 KB |
Output is correct |
66 |
Correct |
262 ms |
2464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
2652 KB |
Output is correct |
2 |
Correct |
8 ms |
2652 KB |
Output is correct |
3 |
Correct |
2 ms |
1372 KB |
Output is correct |
4 |
Correct |
6 ms |
2652 KB |
Output is correct |
5 |
Correct |
14 ms |
2512 KB |
Output is correct |
6 |
Correct |
10 ms |
2652 KB |
Output is correct |
7 |
Correct |
8 ms |
2652 KB |
Output is correct |
8 |
Correct |
16 ms |
2904 KB |
Output is correct |
9 |
Correct |
12 ms |
2652 KB |
Output is correct |
10 |
Correct |
29 ms |
2508 KB |
Output is correct |
11 |
Correct |
31 ms |
2652 KB |
Output is correct |
12 |
Correct |
37 ms |
2468 KB |
Output is correct |
13 |
Correct |
25 ms |
2652 KB |
Output is correct |
14 |
Correct |
26 ms |
2652 KB |
Output is correct |
15 |
Correct |
29 ms |
2652 KB |
Output is correct |
16 |
Correct |
33 ms |
2652 KB |
Output is correct |
17 |
Correct |
19 ms |
2652 KB |
Output is correct |
18 |
Correct |
23 ms |
2652 KB |
Output is correct |
19 |
Correct |
25 ms |
2652 KB |
Output is correct |
20 |
Correct |
26 ms |
2472 KB |
Output is correct |
21 |
Correct |
57 ms |
2644 KB |
Output is correct |
22 |
Correct |
67 ms |
2652 KB |
Output is correct |
23 |
Correct |
56 ms |
2640 KB |
Output is correct |
24 |
Correct |
90 ms |
2632 KB |
Output is correct |
25 |
Correct |
95 ms |
2632 KB |
Output is correct |
26 |
Correct |
85 ms |
2652 KB |
Output is correct |
27 |
Correct |
93 ms |
2640 KB |
Output is correct |
28 |
Correct |
96 ms |
2640 KB |
Output is correct |
29 |
Correct |
87 ms |
2644 KB |
Output is correct |
30 |
Correct |
91 ms |
2388 KB |
Output is correct |
31 |
Correct |
101 ms |
2704 KB |
Output is correct |
32 |
Correct |
89 ms |
2644 KB |
Output is correct |
33 |
Correct |
87 ms |
2636 KB |
Output is correct |
34 |
Correct |
85 ms |
2632 KB |
Output is correct |
35 |
Correct |
97 ms |
2644 KB |
Output is correct |
36 |
Correct |
87 ms |
2632 KB |
Output is correct |
37 |
Correct |
167 ms |
2460 KB |
Output is correct |
38 |
Correct |
174 ms |
2440 KB |
Output is correct |
39 |
Correct |
218 ms |
2644 KB |
Output is correct |
40 |
Correct |
225 ms |
2636 KB |
Output is correct |
41 |
Correct |
227 ms |
2464 KB |
Output is correct |
42 |
Correct |
217 ms |
2900 KB |
Output is correct |
43 |
Correct |
211 ms |
2644 KB |
Output is correct |
44 |
Correct |
235 ms |
2644 KB |
Output is correct |
45 |
Correct |
224 ms |
2644 KB |
Output is correct |
46 |
Correct |
232 ms |
2388 KB |
Output is correct |
47 |
Correct |
217 ms |
2636 KB |
Output is correct |
48 |
Correct |
216 ms |
2632 KB |
Output is correct |
49 |
Correct |
230 ms |
2644 KB |
Output is correct |
50 |
Correct |
215 ms |
2644 KB |
Output is correct |
51 |
Correct |
75 ms |
1420 KB |
Output is correct |
52 |
Correct |
241 ms |
2644 KB |
Output is correct |
53 |
Correct |
260 ms |
2712 KB |
Output is correct |
54 |
Correct |
292 ms |
2636 KB |
Output is correct |
55 |
Correct |
315 ms |
2888 KB |
Output is correct |
56 |
Correct |
261 ms |
2648 KB |
Output is correct |
57 |
Correct |
316 ms |
2700 KB |
Output is correct |
58 |
Correct |
309 ms |
2644 KB |
Output is correct |
59 |
Correct |
305 ms |
2636 KB |
Output is correct |
60 |
Correct |
105 ms |
1416 KB |
Output is correct |
61 |
Correct |
347 ms |
2632 KB |
Output is correct |
62 |
Correct |
304 ms |
2900 KB |
Output is correct |
63 |
Correct |
278 ms |
2676 KB |
Output is correct |
64 |
Correct |
271 ms |
2900 KB |
Output is correct |
65 |
Correct |
280 ms |
2456 KB |
Output is correct |
66 |
Correct |
262 ms |
2464 KB |
Output is correct |
67 |
Correct |
344 ms |
2700 KB |
Output is correct |
68 |
Correct |
155 ms |
1416 KB |
Output is correct |
69 |
Correct |
449 ms |
3156 KB |
Output is correct |
70 |
Correct |
437 ms |
2892 KB |
Output is correct |
71 |
Incorrect |
429 ms |
2892 KB |
Output isn't correct |
72 |
Halted |
0 ms |
0 KB |
- |