#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
const int nx=505, kx=250005;
int n, a[nx], sm;
bitset<kx> dp[nx];
vector<int> res;
bool valid(int x)
{
for (int i=1; i<=n; i++) if (((sm-a[i]+x)%2)||(!dp[i][(sm-a[i]+x)/2])) return 0;
return 1;
}
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n;
for (int i=1; i<=n; i++) cin>>a[i], sm+=a[i];
for (int i=0; i<=n; i++) dp[i][0]=1;
for (int i=1; i<=n; i++) dp[0]=dp[0]|(dp[0]<<a[i]);
for (int i=1; i<=n; i++) for (int j=1; j<=n; j++) if (j!=i) dp[i]=dp[i]|(dp[i]<<a[j]);
if ((sm%2)||!dp[0][sm/2]) return cout<<0, 0;
for (int i=1; i<kx; i++) if (valid(i)) res.push_back(i);
cout<<res.size()<<'\n';
for (auto x:res) cout<<x<<' ';
}
/*
4
1 3 1 5
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
2 ms |
2652 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
2652 KB |
Output is correct |
6 |
Correct |
2 ms |
2648 KB |
Output is correct |
7 |
Correct |
1 ms |
2652 KB |
Output is correct |
8 |
Correct |
2 ms |
2652 KB |
Output is correct |
9 |
Correct |
2 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
2 ms |
2652 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
2652 KB |
Output is correct |
6 |
Correct |
2 ms |
2648 KB |
Output is correct |
7 |
Correct |
1 ms |
2652 KB |
Output is correct |
8 |
Correct |
2 ms |
2652 KB |
Output is correct |
9 |
Correct |
2 ms |
2652 KB |
Output is correct |
10 |
Correct |
7 ms |
2652 KB |
Output is correct |
11 |
Correct |
7 ms |
2648 KB |
Output is correct |
12 |
Correct |
7 ms |
2652 KB |
Output is correct |
13 |
Correct |
6 ms |
2648 KB |
Output is correct |
14 |
Correct |
6 ms |
2596 KB |
Output is correct |
15 |
Correct |
6 ms |
2720 KB |
Output is correct |
16 |
Correct |
8 ms |
2652 KB |
Output is correct |
17 |
Correct |
3 ms |
2648 KB |
Output is correct |
18 |
Correct |
5 ms |
2652 KB |
Output is correct |
19 |
Correct |
7 ms |
2652 KB |
Output is correct |
20 |
Correct |
7 ms |
2648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
2 ms |
2652 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
2652 KB |
Output is correct |
6 |
Correct |
2 ms |
2648 KB |
Output is correct |
7 |
Correct |
1 ms |
2652 KB |
Output is correct |
8 |
Correct |
2 ms |
2652 KB |
Output is correct |
9 |
Correct |
2 ms |
2652 KB |
Output is correct |
10 |
Correct |
7 ms |
2652 KB |
Output is correct |
11 |
Correct |
7 ms |
2648 KB |
Output is correct |
12 |
Correct |
7 ms |
2652 KB |
Output is correct |
13 |
Correct |
6 ms |
2648 KB |
Output is correct |
14 |
Correct |
6 ms |
2596 KB |
Output is correct |
15 |
Correct |
6 ms |
2720 KB |
Output is correct |
16 |
Correct |
8 ms |
2652 KB |
Output is correct |
17 |
Correct |
3 ms |
2648 KB |
Output is correct |
18 |
Correct |
5 ms |
2652 KB |
Output is correct |
19 |
Correct |
7 ms |
2652 KB |
Output is correct |
20 |
Correct |
7 ms |
2648 KB |
Output is correct |
21 |
Correct |
31 ms |
2748 KB |
Output is correct |
22 |
Correct |
39 ms |
4700 KB |
Output is correct |
23 |
Correct |
19 ms |
2648 KB |
Output is correct |
24 |
Correct |
61 ms |
4696 KB |
Output is correct |
25 |
Correct |
62 ms |
4700 KB |
Output is correct |
26 |
Correct |
73 ms |
4780 KB |
Output is correct |
27 |
Correct |
69 ms |
4776 KB |
Output is correct |
28 |
Correct |
69 ms |
4772 KB |
Output is correct |
29 |
Correct |
69 ms |
4776 KB |
Output is correct |
30 |
Correct |
68 ms |
4700 KB |
Output is correct |
31 |
Correct |
71 ms |
4792 KB |
Output is correct |
32 |
Correct |
69 ms |
4772 KB |
Output is correct |
33 |
Correct |
69 ms |
4700 KB |
Output is correct |
34 |
Correct |
69 ms |
4696 KB |
Output is correct |
35 |
Correct |
69 ms |
4700 KB |
Output is correct |
36 |
Correct |
71 ms |
4784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
2 ms |
2652 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
2652 KB |
Output is correct |
6 |
Correct |
2 ms |
2648 KB |
Output is correct |
7 |
Correct |
1 ms |
2652 KB |
Output is correct |
8 |
Correct |
2 ms |
2652 KB |
Output is correct |
9 |
Correct |
2 ms |
2652 KB |
Output is correct |
10 |
Correct |
7 ms |
2652 KB |
Output is correct |
11 |
Correct |
7 ms |
2648 KB |
Output is correct |
12 |
Correct |
7 ms |
2652 KB |
Output is correct |
13 |
Correct |
6 ms |
2648 KB |
Output is correct |
14 |
Correct |
6 ms |
2596 KB |
Output is correct |
15 |
Correct |
6 ms |
2720 KB |
Output is correct |
16 |
Correct |
8 ms |
2652 KB |
Output is correct |
17 |
Correct |
3 ms |
2648 KB |
Output is correct |
18 |
Correct |
5 ms |
2652 KB |
Output is correct |
19 |
Correct |
7 ms |
2652 KB |
Output is correct |
20 |
Correct |
7 ms |
2648 KB |
Output is correct |
21 |
Correct |
31 ms |
2748 KB |
Output is correct |
22 |
Correct |
39 ms |
4700 KB |
Output is correct |
23 |
Correct |
19 ms |
2648 KB |
Output is correct |
24 |
Correct |
61 ms |
4696 KB |
Output is correct |
25 |
Correct |
62 ms |
4700 KB |
Output is correct |
26 |
Correct |
73 ms |
4780 KB |
Output is correct |
27 |
Correct |
69 ms |
4776 KB |
Output is correct |
28 |
Correct |
69 ms |
4772 KB |
Output is correct |
29 |
Correct |
69 ms |
4776 KB |
Output is correct |
30 |
Correct |
68 ms |
4700 KB |
Output is correct |
31 |
Correct |
71 ms |
4792 KB |
Output is correct |
32 |
Correct |
69 ms |
4772 KB |
Output is correct |
33 |
Correct |
69 ms |
4700 KB |
Output is correct |
34 |
Correct |
69 ms |
4696 KB |
Output is correct |
35 |
Correct |
69 ms |
4700 KB |
Output is correct |
36 |
Correct |
71 ms |
4784 KB |
Output is correct |
37 |
Correct |
281 ms |
6844 KB |
Output is correct |
38 |
Correct |
275 ms |
6848 KB |
Output is correct |
39 |
Correct |
419 ms |
9044 KB |
Output is correct |
40 |
Correct |
504 ms |
8880 KB |
Output is correct |
41 |
Correct |
499 ms |
8796 KB |
Output is correct |
42 |
Correct |
433 ms |
9040 KB |
Output is correct |
43 |
Correct |
414 ms |
9140 KB |
Output is correct |
44 |
Correct |
451 ms |
9144 KB |
Output is correct |
45 |
Correct |
440 ms |
9136 KB |
Output is correct |
46 |
Correct |
487 ms |
8796 KB |
Output is correct |
47 |
Correct |
433 ms |
9044 KB |
Output is correct |
48 |
Correct |
434 ms |
9140 KB |
Output is correct |
49 |
Correct |
427 ms |
8880 KB |
Output is correct |
50 |
Correct |
434 ms |
9044 KB |
Output is correct |
51 |
Correct |
425 ms |
8880 KB |
Output is correct |
52 |
Correct |
508 ms |
9248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
2 ms |
2652 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
2652 KB |
Output is correct |
6 |
Correct |
2 ms |
2648 KB |
Output is correct |
7 |
Correct |
1 ms |
2652 KB |
Output is correct |
8 |
Correct |
2 ms |
2652 KB |
Output is correct |
9 |
Correct |
2 ms |
2652 KB |
Output is correct |
10 |
Correct |
7 ms |
2652 KB |
Output is correct |
11 |
Correct |
7 ms |
2648 KB |
Output is correct |
12 |
Correct |
7 ms |
2652 KB |
Output is correct |
13 |
Correct |
6 ms |
2648 KB |
Output is correct |
14 |
Correct |
6 ms |
2596 KB |
Output is correct |
15 |
Correct |
6 ms |
2720 KB |
Output is correct |
16 |
Correct |
8 ms |
2652 KB |
Output is correct |
17 |
Correct |
3 ms |
2648 KB |
Output is correct |
18 |
Correct |
5 ms |
2652 KB |
Output is correct |
19 |
Correct |
7 ms |
2652 KB |
Output is correct |
20 |
Correct |
7 ms |
2648 KB |
Output is correct |
21 |
Correct |
31 ms |
2748 KB |
Output is correct |
22 |
Correct |
39 ms |
4700 KB |
Output is correct |
23 |
Correct |
19 ms |
2648 KB |
Output is correct |
24 |
Correct |
61 ms |
4696 KB |
Output is correct |
25 |
Correct |
62 ms |
4700 KB |
Output is correct |
26 |
Correct |
73 ms |
4780 KB |
Output is correct |
27 |
Correct |
69 ms |
4776 KB |
Output is correct |
28 |
Correct |
69 ms |
4772 KB |
Output is correct |
29 |
Correct |
69 ms |
4776 KB |
Output is correct |
30 |
Correct |
68 ms |
4700 KB |
Output is correct |
31 |
Correct |
71 ms |
4792 KB |
Output is correct |
32 |
Correct |
69 ms |
4772 KB |
Output is correct |
33 |
Correct |
69 ms |
4700 KB |
Output is correct |
34 |
Correct |
69 ms |
4696 KB |
Output is correct |
35 |
Correct |
69 ms |
4700 KB |
Output is correct |
36 |
Correct |
71 ms |
4784 KB |
Output is correct |
37 |
Correct |
281 ms |
6844 KB |
Output is correct |
38 |
Correct |
275 ms |
6848 KB |
Output is correct |
39 |
Correct |
419 ms |
9044 KB |
Output is correct |
40 |
Correct |
504 ms |
8880 KB |
Output is correct |
41 |
Correct |
499 ms |
8796 KB |
Output is correct |
42 |
Correct |
433 ms |
9040 KB |
Output is correct |
43 |
Correct |
414 ms |
9140 KB |
Output is correct |
44 |
Correct |
451 ms |
9144 KB |
Output is correct |
45 |
Correct |
440 ms |
9136 KB |
Output is correct |
46 |
Correct |
487 ms |
8796 KB |
Output is correct |
47 |
Correct |
433 ms |
9044 KB |
Output is correct |
48 |
Correct |
434 ms |
9140 KB |
Output is correct |
49 |
Correct |
427 ms |
8880 KB |
Output is correct |
50 |
Correct |
434 ms |
9044 KB |
Output is correct |
51 |
Correct |
425 ms |
8880 KB |
Output is correct |
52 |
Correct |
508 ms |
9248 KB |
Output is correct |
53 |
Correct |
621 ms |
11188 KB |
Output is correct |
54 |
Correct |
860 ms |
13244 KB |
Output is correct |
55 |
Correct |
859 ms |
13384 KB |
Output is correct |
56 |
Correct |
663 ms |
11192 KB |
Output is correct |
57 |
Correct |
859 ms |
13540 KB |
Output is correct |
58 |
Correct |
853 ms |
13372 KB |
Output is correct |
59 |
Correct |
856 ms |
13384 KB |
Output is correct |
60 |
Correct |
826 ms |
12924 KB |
Output is correct |
61 |
Correct |
861 ms |
13376 KB |
Output is correct |
62 |
Correct |
724 ms |
11352 KB |
Output is correct |
63 |
Correct |
732 ms |
11324 KB |
Output is correct |
64 |
Correct |
709 ms |
11324 KB |
Output is correct |
65 |
Correct |
684 ms |
11092 KB |
Output is correct |
66 |
Correct |
660 ms |
10932 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
2 ms |
2652 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
2652 KB |
Output is correct |
6 |
Correct |
2 ms |
2648 KB |
Output is correct |
7 |
Correct |
1 ms |
2652 KB |
Output is correct |
8 |
Correct |
2 ms |
2652 KB |
Output is correct |
9 |
Correct |
2 ms |
2652 KB |
Output is correct |
10 |
Correct |
7 ms |
2652 KB |
Output is correct |
11 |
Correct |
7 ms |
2648 KB |
Output is correct |
12 |
Correct |
7 ms |
2652 KB |
Output is correct |
13 |
Correct |
6 ms |
2648 KB |
Output is correct |
14 |
Correct |
6 ms |
2596 KB |
Output is correct |
15 |
Correct |
6 ms |
2720 KB |
Output is correct |
16 |
Correct |
8 ms |
2652 KB |
Output is correct |
17 |
Correct |
3 ms |
2648 KB |
Output is correct |
18 |
Correct |
5 ms |
2652 KB |
Output is correct |
19 |
Correct |
7 ms |
2652 KB |
Output is correct |
20 |
Correct |
7 ms |
2648 KB |
Output is correct |
21 |
Correct |
31 ms |
2748 KB |
Output is correct |
22 |
Correct |
39 ms |
4700 KB |
Output is correct |
23 |
Correct |
19 ms |
2648 KB |
Output is correct |
24 |
Correct |
61 ms |
4696 KB |
Output is correct |
25 |
Correct |
62 ms |
4700 KB |
Output is correct |
26 |
Correct |
73 ms |
4780 KB |
Output is correct |
27 |
Correct |
69 ms |
4776 KB |
Output is correct |
28 |
Correct |
69 ms |
4772 KB |
Output is correct |
29 |
Correct |
69 ms |
4776 KB |
Output is correct |
30 |
Correct |
68 ms |
4700 KB |
Output is correct |
31 |
Correct |
71 ms |
4792 KB |
Output is correct |
32 |
Correct |
69 ms |
4772 KB |
Output is correct |
33 |
Correct |
69 ms |
4700 KB |
Output is correct |
34 |
Correct |
69 ms |
4696 KB |
Output is correct |
35 |
Correct |
69 ms |
4700 KB |
Output is correct |
36 |
Correct |
71 ms |
4784 KB |
Output is correct |
37 |
Correct |
281 ms |
6844 KB |
Output is correct |
38 |
Correct |
275 ms |
6848 KB |
Output is correct |
39 |
Correct |
419 ms |
9044 KB |
Output is correct |
40 |
Correct |
504 ms |
8880 KB |
Output is correct |
41 |
Correct |
499 ms |
8796 KB |
Output is correct |
42 |
Correct |
433 ms |
9040 KB |
Output is correct |
43 |
Correct |
414 ms |
9140 KB |
Output is correct |
44 |
Correct |
451 ms |
9144 KB |
Output is correct |
45 |
Correct |
440 ms |
9136 KB |
Output is correct |
46 |
Correct |
487 ms |
8796 KB |
Output is correct |
47 |
Correct |
433 ms |
9044 KB |
Output is correct |
48 |
Correct |
434 ms |
9140 KB |
Output is correct |
49 |
Correct |
427 ms |
8880 KB |
Output is correct |
50 |
Correct |
434 ms |
9044 KB |
Output is correct |
51 |
Correct |
425 ms |
8880 KB |
Output is correct |
52 |
Correct |
508 ms |
9248 KB |
Output is correct |
53 |
Correct |
621 ms |
11188 KB |
Output is correct |
54 |
Correct |
860 ms |
13244 KB |
Output is correct |
55 |
Correct |
859 ms |
13384 KB |
Output is correct |
56 |
Correct |
663 ms |
11192 KB |
Output is correct |
57 |
Correct |
859 ms |
13540 KB |
Output is correct |
58 |
Correct |
853 ms |
13372 KB |
Output is correct |
59 |
Correct |
856 ms |
13384 KB |
Output is correct |
60 |
Correct |
826 ms |
12924 KB |
Output is correct |
61 |
Correct |
861 ms |
13376 KB |
Output is correct |
62 |
Correct |
724 ms |
11352 KB |
Output is correct |
63 |
Correct |
732 ms |
11324 KB |
Output is correct |
64 |
Correct |
709 ms |
11324 KB |
Output is correct |
65 |
Correct |
684 ms |
11092 KB |
Output is correct |
66 |
Correct |
660 ms |
10932 KB |
Output is correct |
67 |
Execution timed out |
1024 ms |
12888 KB |
Time limit exceeded |
68 |
Halted |
0 ms |
0 KB |
- |