#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cassert>
#define int int64_t
using namespace std;
signed main()
{
int n;
cin >> n;
int m = 600*n;
vector<int> v(n);
for (int i = 0; i < n; i++) cin >> v[i];
int ssum = accumulate(v.begin(), v.end(), 0);
vector<int> dp(m);
dp[0] = 1;
for (int i = 0; i < n; i++)
{
for (int j = m - 1; j >= v[i]; j--) dp[j] += dp[j - v[i]];
}
if (ssum % 2 == 1 || (!dp[ssum/2]))
{
cout << "0\n";
return 0;
}
vector<int> res(m, 0);
for (int i = 0; i < n; i++)
{
vector<int> poss(m);
for (int j = 0; j < m; j++)
{
poss[j] = dp[j] - (j >= v[i] ? poss[j - v[i]] : 0);
}
for (int j = 0; j < m; j++)
{
int sm = ssum - v[i] + j;
if (sm % 2 == 0 && poss[sm >> 1]) res[j]++;
}
}
int r = count(res.begin() + 1, res.end(), n);
cout << r << "\n";
for (int i = 1; i <= m; i++) if (res[i] == n) cout << i << " ";
cout << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
512 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
512 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
512 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
512 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
10 |
Correct |
7 ms |
768 KB |
Output is correct |
11 |
Correct |
7 ms |
768 KB |
Output is correct |
12 |
Correct |
7 ms |
768 KB |
Output is correct |
13 |
Correct |
6 ms |
640 KB |
Output is correct |
14 |
Correct |
7 ms |
768 KB |
Output is correct |
15 |
Correct |
7 ms |
768 KB |
Output is correct |
16 |
Correct |
9 ms |
768 KB |
Output is correct |
17 |
Correct |
6 ms |
692 KB |
Output is correct |
18 |
Correct |
6 ms |
640 KB |
Output is correct |
19 |
Correct |
7 ms |
768 KB |
Output is correct |
20 |
Correct |
7 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
512 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
512 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
10 |
Correct |
7 ms |
768 KB |
Output is correct |
11 |
Correct |
7 ms |
768 KB |
Output is correct |
12 |
Correct |
7 ms |
768 KB |
Output is correct |
13 |
Correct |
6 ms |
640 KB |
Output is correct |
14 |
Correct |
7 ms |
768 KB |
Output is correct |
15 |
Correct |
7 ms |
768 KB |
Output is correct |
16 |
Correct |
9 ms |
768 KB |
Output is correct |
17 |
Correct |
6 ms |
692 KB |
Output is correct |
18 |
Correct |
6 ms |
640 KB |
Output is correct |
19 |
Correct |
7 ms |
768 KB |
Output is correct |
20 |
Correct |
7 ms |
768 KB |
Output is correct |
21 |
Correct |
15 ms |
1280 KB |
Output is correct |
22 |
Correct |
18 ms |
1316 KB |
Output is correct |
23 |
Correct |
16 ms |
1044 KB |
Output is correct |
24 |
Correct |
26 ms |
1664 KB |
Output is correct |
25 |
Correct |
25 ms |
1732 KB |
Output is correct |
26 |
Correct |
28 ms |
1792 KB |
Output is correct |
27 |
Correct |
28 ms |
1792 KB |
Output is correct |
28 |
Correct |
28 ms |
1792 KB |
Output is correct |
29 |
Correct |
27 ms |
1792 KB |
Output is correct |
30 |
Correct |
30 ms |
1792 KB |
Output is correct |
31 |
Correct |
29 ms |
1792 KB |
Output is correct |
32 |
Correct |
28 ms |
1792 KB |
Output is correct |
33 |
Correct |
27 ms |
1792 KB |
Output is correct |
34 |
Correct |
29 ms |
1792 KB |
Output is correct |
35 |
Correct |
35 ms |
1792 KB |
Output is correct |
36 |
Correct |
28 ms |
1824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
512 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
512 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
10 |
Correct |
7 ms |
768 KB |
Output is correct |
11 |
Correct |
7 ms |
768 KB |
Output is correct |
12 |
Correct |
7 ms |
768 KB |
Output is correct |
13 |
Correct |
6 ms |
640 KB |
Output is correct |
14 |
Correct |
7 ms |
768 KB |
Output is correct |
15 |
Correct |
7 ms |
768 KB |
Output is correct |
16 |
Correct |
9 ms |
768 KB |
Output is correct |
17 |
Correct |
6 ms |
692 KB |
Output is correct |
18 |
Correct |
6 ms |
640 KB |
Output is correct |
19 |
Correct |
7 ms |
768 KB |
Output is correct |
20 |
Correct |
7 ms |
768 KB |
Output is correct |
21 |
Correct |
15 ms |
1280 KB |
Output is correct |
22 |
Correct |
18 ms |
1316 KB |
Output is correct |
23 |
Correct |
16 ms |
1044 KB |
Output is correct |
24 |
Correct |
26 ms |
1664 KB |
Output is correct |
25 |
Correct |
25 ms |
1732 KB |
Output is correct |
26 |
Correct |
28 ms |
1792 KB |
Output is correct |
27 |
Correct |
28 ms |
1792 KB |
Output is correct |
28 |
Correct |
28 ms |
1792 KB |
Output is correct |
29 |
Correct |
27 ms |
1792 KB |
Output is correct |
30 |
Correct |
30 ms |
1792 KB |
Output is correct |
31 |
Correct |
29 ms |
1792 KB |
Output is correct |
32 |
Correct |
28 ms |
1792 KB |
Output is correct |
33 |
Correct |
27 ms |
1792 KB |
Output is correct |
34 |
Correct |
29 ms |
1792 KB |
Output is correct |
35 |
Correct |
35 ms |
1792 KB |
Output is correct |
36 |
Correct |
28 ms |
1824 KB |
Output is correct |
37 |
Correct |
93 ms |
3200 KB |
Output is correct |
38 |
Correct |
94 ms |
3352 KB |
Output is correct |
39 |
Correct |
149 ms |
3948 KB |
Output is correct |
40 |
Correct |
169 ms |
4228 KB |
Output is correct |
41 |
Correct |
168 ms |
4216 KB |
Output is correct |
42 |
Correct |
145 ms |
3940 KB |
Output is correct |
43 |
Correct |
150 ms |
3840 KB |
Output is correct |
44 |
Correct |
149 ms |
4076 KB |
Output is correct |
45 |
Correct |
153 ms |
4064 KB |
Output is correct |
46 |
Correct |
166 ms |
4100 KB |
Output is correct |
47 |
Correct |
149 ms |
4004 KB |
Output is correct |
48 |
Correct |
145 ms |
3940 KB |
Output is correct |
49 |
Correct |
150 ms |
3832 KB |
Output is correct |
50 |
Correct |
145 ms |
3936 KB |
Output is correct |
51 |
Correct |
33 ms |
1536 KB |
Output is correct |
52 |
Correct |
170 ms |
4228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
512 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
512 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
10 |
Correct |
7 ms |
768 KB |
Output is correct |
11 |
Correct |
7 ms |
768 KB |
Output is correct |
12 |
Correct |
7 ms |
768 KB |
Output is correct |
13 |
Correct |
6 ms |
640 KB |
Output is correct |
14 |
Correct |
7 ms |
768 KB |
Output is correct |
15 |
Correct |
7 ms |
768 KB |
Output is correct |
16 |
Correct |
9 ms |
768 KB |
Output is correct |
17 |
Correct |
6 ms |
692 KB |
Output is correct |
18 |
Correct |
6 ms |
640 KB |
Output is correct |
19 |
Correct |
7 ms |
768 KB |
Output is correct |
20 |
Correct |
7 ms |
768 KB |
Output is correct |
21 |
Correct |
15 ms |
1280 KB |
Output is correct |
22 |
Correct |
18 ms |
1316 KB |
Output is correct |
23 |
Correct |
16 ms |
1044 KB |
Output is correct |
24 |
Correct |
26 ms |
1664 KB |
Output is correct |
25 |
Correct |
25 ms |
1732 KB |
Output is correct |
26 |
Correct |
28 ms |
1792 KB |
Output is correct |
27 |
Correct |
28 ms |
1792 KB |
Output is correct |
28 |
Correct |
28 ms |
1792 KB |
Output is correct |
29 |
Correct |
27 ms |
1792 KB |
Output is correct |
30 |
Correct |
30 ms |
1792 KB |
Output is correct |
31 |
Correct |
29 ms |
1792 KB |
Output is correct |
32 |
Correct |
28 ms |
1792 KB |
Output is correct |
33 |
Correct |
27 ms |
1792 KB |
Output is correct |
34 |
Correct |
29 ms |
1792 KB |
Output is correct |
35 |
Correct |
35 ms |
1792 KB |
Output is correct |
36 |
Correct |
28 ms |
1824 KB |
Output is correct |
37 |
Correct |
93 ms |
3200 KB |
Output is correct |
38 |
Correct |
94 ms |
3352 KB |
Output is correct |
39 |
Correct |
149 ms |
3948 KB |
Output is correct |
40 |
Correct |
169 ms |
4228 KB |
Output is correct |
41 |
Correct |
168 ms |
4216 KB |
Output is correct |
42 |
Correct |
145 ms |
3940 KB |
Output is correct |
43 |
Correct |
150 ms |
3840 KB |
Output is correct |
44 |
Correct |
149 ms |
4076 KB |
Output is correct |
45 |
Correct |
153 ms |
4064 KB |
Output is correct |
46 |
Correct |
166 ms |
4100 KB |
Output is correct |
47 |
Correct |
149 ms |
4004 KB |
Output is correct |
48 |
Correct |
145 ms |
3940 KB |
Output is correct |
49 |
Correct |
150 ms |
3832 KB |
Output is correct |
50 |
Correct |
145 ms |
3936 KB |
Output is correct |
51 |
Correct |
33 ms |
1536 KB |
Output is correct |
52 |
Correct |
170 ms |
4228 KB |
Output is correct |
53 |
Correct |
207 ms |
4700 KB |
Output is correct |
54 |
Correct |
283 ms |
5512 KB |
Output is correct |
55 |
Correct |
281 ms |
5516 KB |
Output is correct |
56 |
Correct |
217 ms |
4824 KB |
Output is correct |
57 |
Correct |
293 ms |
5512 KB |
Output is correct |
58 |
Correct |
278 ms |
5384 KB |
Output is correct |
59 |
Correct |
290 ms |
5512 KB |
Output is correct |
60 |
Correct |
65 ms |
1920 KB |
Output is correct |
61 |
Correct |
293 ms |
5512 KB |
Output is correct |
62 |
Correct |
246 ms |
5268 KB |
Output is correct |
63 |
Correct |
243 ms |
5140 KB |
Output is correct |
64 |
Correct |
235 ms |
5048 KB |
Output is correct |
65 |
Correct |
257 ms |
4856 KB |
Output is correct |
66 |
Correct |
224 ms |
4768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
512 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
512 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
10 |
Correct |
7 ms |
768 KB |
Output is correct |
11 |
Correct |
7 ms |
768 KB |
Output is correct |
12 |
Correct |
7 ms |
768 KB |
Output is correct |
13 |
Correct |
6 ms |
640 KB |
Output is correct |
14 |
Correct |
7 ms |
768 KB |
Output is correct |
15 |
Correct |
7 ms |
768 KB |
Output is correct |
16 |
Correct |
9 ms |
768 KB |
Output is correct |
17 |
Correct |
6 ms |
692 KB |
Output is correct |
18 |
Correct |
6 ms |
640 KB |
Output is correct |
19 |
Correct |
7 ms |
768 KB |
Output is correct |
20 |
Correct |
7 ms |
768 KB |
Output is correct |
21 |
Correct |
15 ms |
1280 KB |
Output is correct |
22 |
Correct |
18 ms |
1316 KB |
Output is correct |
23 |
Correct |
16 ms |
1044 KB |
Output is correct |
24 |
Correct |
26 ms |
1664 KB |
Output is correct |
25 |
Correct |
25 ms |
1732 KB |
Output is correct |
26 |
Correct |
28 ms |
1792 KB |
Output is correct |
27 |
Correct |
28 ms |
1792 KB |
Output is correct |
28 |
Correct |
28 ms |
1792 KB |
Output is correct |
29 |
Correct |
27 ms |
1792 KB |
Output is correct |
30 |
Correct |
30 ms |
1792 KB |
Output is correct |
31 |
Correct |
29 ms |
1792 KB |
Output is correct |
32 |
Correct |
28 ms |
1792 KB |
Output is correct |
33 |
Correct |
27 ms |
1792 KB |
Output is correct |
34 |
Correct |
29 ms |
1792 KB |
Output is correct |
35 |
Correct |
35 ms |
1792 KB |
Output is correct |
36 |
Correct |
28 ms |
1824 KB |
Output is correct |
37 |
Correct |
93 ms |
3200 KB |
Output is correct |
38 |
Correct |
94 ms |
3352 KB |
Output is correct |
39 |
Correct |
149 ms |
3948 KB |
Output is correct |
40 |
Correct |
169 ms |
4228 KB |
Output is correct |
41 |
Correct |
168 ms |
4216 KB |
Output is correct |
42 |
Correct |
145 ms |
3940 KB |
Output is correct |
43 |
Correct |
150 ms |
3840 KB |
Output is correct |
44 |
Correct |
149 ms |
4076 KB |
Output is correct |
45 |
Correct |
153 ms |
4064 KB |
Output is correct |
46 |
Correct |
166 ms |
4100 KB |
Output is correct |
47 |
Correct |
149 ms |
4004 KB |
Output is correct |
48 |
Correct |
145 ms |
3940 KB |
Output is correct |
49 |
Correct |
150 ms |
3832 KB |
Output is correct |
50 |
Correct |
145 ms |
3936 KB |
Output is correct |
51 |
Correct |
33 ms |
1536 KB |
Output is correct |
52 |
Correct |
170 ms |
4228 KB |
Output is correct |
53 |
Correct |
207 ms |
4700 KB |
Output is correct |
54 |
Correct |
283 ms |
5512 KB |
Output is correct |
55 |
Correct |
281 ms |
5516 KB |
Output is correct |
56 |
Correct |
217 ms |
4824 KB |
Output is correct |
57 |
Correct |
293 ms |
5512 KB |
Output is correct |
58 |
Correct |
278 ms |
5384 KB |
Output is correct |
59 |
Correct |
290 ms |
5512 KB |
Output is correct |
60 |
Correct |
65 ms |
1920 KB |
Output is correct |
61 |
Correct |
293 ms |
5512 KB |
Output is correct |
62 |
Correct |
246 ms |
5268 KB |
Output is correct |
63 |
Correct |
243 ms |
5140 KB |
Output is correct |
64 |
Correct |
235 ms |
5048 KB |
Output is correct |
65 |
Correct |
257 ms |
4856 KB |
Output is correct |
66 |
Correct |
224 ms |
4768 KB |
Output is correct |
67 |
Correct |
389 ms |
6156 KB |
Output is correct |
68 |
Correct |
131 ms |
2732 KB |
Output is correct |
69 |
Correct |
624 ms |
8072 KB |
Output is correct |
70 |
Correct |
596 ms |
7756 KB |
Output is correct |
71 |
Correct |
574 ms |
7884 KB |
Output is correct |
72 |
Correct |
582 ms |
7504 KB |
Output is correct |
73 |
Correct |
619 ms |
7416 KB |
Output is correct |
74 |
Correct |
613 ms |
8124 KB |
Output is correct |
75 |
Correct |
595 ms |
7892 KB |
Output is correct |
76 |
Correct |
622 ms |
8080 KB |
Output is correct |
77 |
Correct |
596 ms |
8144 KB |
Output is correct |