#include <bits/stdc++.h>
using namespace std;
int g[250005], f[250005], a[505];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, sum=0, ans=0;
cin >> n;
f[0]=1;
for (int i=1; i<=n; i++)
{
cin >> a[i];
for (int j=sum; j>=0; j--)
f[j+a[i]]+=f[j];
sum+=a[i];
}
for (int i=1; i<=n; i++)
{
sum-=a[i];
for (int j=0; j<=sum; j++)
{
f[j+a[i]]-=f[j];
if (f[j])
g[max(0, j*2-sum)]++;
}
for (int j=sum; j>=0; j--)
f[j+a[i]]+=f[j];
sum+=a[i];
}
if (sum&1 || !f[sum/2])
{
cout << 0;
return 0;
}
for (int i=1; i<=sum; i++)
if (g[i]==n)
ans++;
cout << ans << '\n';
for (int i=1; i<=sum; i++)
if (g[i]==n)
cout << i << ' ';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
328 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
328 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
4 ms |
468 KB |
Output is correct |
26 |
Correct |
3 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
340 KB |
Output is correct |
28 |
Correct |
4 ms |
340 KB |
Output is correct |
29 |
Correct |
3 ms |
340 KB |
Output is correct |
30 |
Correct |
2 ms |
340 KB |
Output is correct |
31 |
Correct |
3 ms |
340 KB |
Output is correct |
32 |
Correct |
2 ms |
352 KB |
Output is correct |
33 |
Correct |
2 ms |
340 KB |
Output is correct |
34 |
Correct |
3 ms |
340 KB |
Output is correct |
35 |
Correct |
4 ms |
332 KB |
Output is correct |
36 |
Correct |
3 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
328 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
4 ms |
468 KB |
Output is correct |
26 |
Correct |
3 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
340 KB |
Output is correct |
28 |
Correct |
4 ms |
340 KB |
Output is correct |
29 |
Correct |
3 ms |
340 KB |
Output is correct |
30 |
Correct |
2 ms |
340 KB |
Output is correct |
31 |
Correct |
3 ms |
340 KB |
Output is correct |
32 |
Correct |
2 ms |
352 KB |
Output is correct |
33 |
Correct |
2 ms |
340 KB |
Output is correct |
34 |
Correct |
3 ms |
340 KB |
Output is correct |
35 |
Correct |
4 ms |
332 KB |
Output is correct |
36 |
Correct |
3 ms |
340 KB |
Output is correct |
37 |
Correct |
12 ms |
460 KB |
Output is correct |
38 |
Correct |
11 ms |
492 KB |
Output is correct |
39 |
Correct |
32 ms |
904 KB |
Output is correct |
40 |
Correct |
25 ms |
588 KB |
Output is correct |
41 |
Correct |
37 ms |
884 KB |
Output is correct |
42 |
Correct |
28 ms |
568 KB |
Output is correct |
43 |
Correct |
34 ms |
880 KB |
Output is correct |
44 |
Correct |
36 ms |
888 KB |
Output is correct |
45 |
Correct |
39 ms |
900 KB |
Output is correct |
46 |
Correct |
20 ms |
572 KB |
Output is correct |
47 |
Correct |
30 ms |
588 KB |
Output is correct |
48 |
Correct |
37 ms |
792 KB |
Output is correct |
49 |
Correct |
33 ms |
812 KB |
Output is correct |
50 |
Correct |
23 ms |
576 KB |
Output is correct |
51 |
Correct |
21 ms |
464 KB |
Output is correct |
52 |
Correct |
48 ms |
992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
328 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
4 ms |
468 KB |
Output is correct |
26 |
Correct |
3 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
340 KB |
Output is correct |
28 |
Correct |
4 ms |
340 KB |
Output is correct |
29 |
Correct |
3 ms |
340 KB |
Output is correct |
30 |
Correct |
2 ms |
340 KB |
Output is correct |
31 |
Correct |
3 ms |
340 KB |
Output is correct |
32 |
Correct |
2 ms |
352 KB |
Output is correct |
33 |
Correct |
2 ms |
340 KB |
Output is correct |
34 |
Correct |
3 ms |
340 KB |
Output is correct |
35 |
Correct |
4 ms |
332 KB |
Output is correct |
36 |
Correct |
3 ms |
340 KB |
Output is correct |
37 |
Correct |
12 ms |
460 KB |
Output is correct |
38 |
Correct |
11 ms |
492 KB |
Output is correct |
39 |
Correct |
32 ms |
904 KB |
Output is correct |
40 |
Correct |
25 ms |
588 KB |
Output is correct |
41 |
Correct |
37 ms |
884 KB |
Output is correct |
42 |
Correct |
28 ms |
568 KB |
Output is correct |
43 |
Correct |
34 ms |
880 KB |
Output is correct |
44 |
Correct |
36 ms |
888 KB |
Output is correct |
45 |
Correct |
39 ms |
900 KB |
Output is correct |
46 |
Correct |
20 ms |
572 KB |
Output is correct |
47 |
Correct |
30 ms |
588 KB |
Output is correct |
48 |
Correct |
37 ms |
792 KB |
Output is correct |
49 |
Correct |
33 ms |
812 KB |
Output is correct |
50 |
Correct |
23 ms |
576 KB |
Output is correct |
51 |
Correct |
21 ms |
464 KB |
Output is correct |
52 |
Correct |
48 ms |
992 KB |
Output is correct |
53 |
Correct |
36 ms |
688 KB |
Output is correct |
54 |
Correct |
61 ms |
884 KB |
Output is correct |
55 |
Correct |
107 ms |
1440 KB |
Output is correct |
56 |
Correct |
47 ms |
880 KB |
Output is correct |
57 |
Correct |
101 ms |
1480 KB |
Output is correct |
58 |
Correct |
61 ms |
920 KB |
Output is correct |
59 |
Correct |
72 ms |
1040 KB |
Output is correct |
60 |
Correct |
59 ms |
788 KB |
Output is correct |
61 |
Correct |
80 ms |
1116 KB |
Output is correct |
62 |
Correct |
88 ms |
1316 KB |
Output is correct |
63 |
Correct |
108 ms |
1392 KB |
Output is correct |
64 |
Correct |
91 ms |
1380 KB |
Output is correct |
65 |
Correct |
47 ms |
688 KB |
Output is correct |
66 |
Correct |
40 ms |
648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
328 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
4 ms |
468 KB |
Output is correct |
26 |
Correct |
3 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
340 KB |
Output is correct |
28 |
Correct |
4 ms |
340 KB |
Output is correct |
29 |
Correct |
3 ms |
340 KB |
Output is correct |
30 |
Correct |
2 ms |
340 KB |
Output is correct |
31 |
Correct |
3 ms |
340 KB |
Output is correct |
32 |
Correct |
2 ms |
352 KB |
Output is correct |
33 |
Correct |
2 ms |
340 KB |
Output is correct |
34 |
Correct |
3 ms |
340 KB |
Output is correct |
35 |
Correct |
4 ms |
332 KB |
Output is correct |
36 |
Correct |
3 ms |
340 KB |
Output is correct |
37 |
Correct |
12 ms |
460 KB |
Output is correct |
38 |
Correct |
11 ms |
492 KB |
Output is correct |
39 |
Correct |
32 ms |
904 KB |
Output is correct |
40 |
Correct |
25 ms |
588 KB |
Output is correct |
41 |
Correct |
37 ms |
884 KB |
Output is correct |
42 |
Correct |
28 ms |
568 KB |
Output is correct |
43 |
Correct |
34 ms |
880 KB |
Output is correct |
44 |
Correct |
36 ms |
888 KB |
Output is correct |
45 |
Correct |
39 ms |
900 KB |
Output is correct |
46 |
Correct |
20 ms |
572 KB |
Output is correct |
47 |
Correct |
30 ms |
588 KB |
Output is correct |
48 |
Correct |
37 ms |
792 KB |
Output is correct |
49 |
Correct |
33 ms |
812 KB |
Output is correct |
50 |
Correct |
23 ms |
576 KB |
Output is correct |
51 |
Correct |
21 ms |
464 KB |
Output is correct |
52 |
Correct |
48 ms |
992 KB |
Output is correct |
53 |
Correct |
36 ms |
688 KB |
Output is correct |
54 |
Correct |
61 ms |
884 KB |
Output is correct |
55 |
Correct |
107 ms |
1440 KB |
Output is correct |
56 |
Correct |
47 ms |
880 KB |
Output is correct |
57 |
Correct |
101 ms |
1480 KB |
Output is correct |
58 |
Correct |
61 ms |
920 KB |
Output is correct |
59 |
Correct |
72 ms |
1040 KB |
Output is correct |
60 |
Correct |
59 ms |
788 KB |
Output is correct |
61 |
Correct |
80 ms |
1116 KB |
Output is correct |
62 |
Correct |
88 ms |
1316 KB |
Output is correct |
63 |
Correct |
108 ms |
1392 KB |
Output is correct |
64 |
Correct |
91 ms |
1380 KB |
Output is correct |
65 |
Correct |
47 ms |
688 KB |
Output is correct |
66 |
Correct |
40 ms |
648 KB |
Output is correct |
67 |
Correct |
91 ms |
1068 KB |
Output is correct |
68 |
Correct |
132 ms |
1276 KB |
Output is correct |
69 |
Correct |
316 ms |
2608 KB |
Output is correct |
70 |
Correct |
172 ms |
1696 KB |
Output is correct |
71 |
Correct |
163 ms |
1668 KB |
Output is correct |
72 |
Correct |
194 ms |
1296 KB |
Output is correct |
73 |
Correct |
177 ms |
1284 KB |
Output is correct |
74 |
Correct |
308 ms |
2700 KB |
Output is correct |
75 |
Correct |
246 ms |
2180 KB |
Output is correct |
76 |
Correct |
316 ms |
2860 KB |
Output is correct |
77 |
Correct |
327 ms |
2884 KB |
Output is correct |