#include <bits/stdc++.h>
using namespace std;
const int MAXN = 502;
int g[MAXN*MAXN];
int ar[MAXN];
int n;
bitset<MAXN * MAXN> kp;
void knap(int ind){
kp.reset();
kp.set(0);
int s =0; for (int i=0; i<n; i++) if (i!= ind) s+=ar[i];
for (int i=0; i<n; i++){
if (i==ind) continue;
kp |= kp<<ar[i];
}
for (int i=1; i<n*MAXN; i++){
if (!kp[i]) continue;
if (2*i-s <= 0) continue;
g[2*i-s] ++;
}
}
int main(){
cin>>n;
for (int i=0; i<n; i++) cin>>ar[i];
if (n&1) {cout<<0; exit(0);}
int s=0; for (int i=0; i<n; i++) s += ar[i];
kp.set(0);
for (int i=0; i<n; i++){
kp |= kp << ar[i];
}
if (!kp[s/2]) {cout<<0; exit(0);}
for (int i=0; i<n; i++){
knap(i);
}
set<int> good;
for (int i=1; i<MAXN*MAXN; i++) if (g[i] == n) good.insert(i);
cout<<good.size()<<'\n';
for (int x: good) cout<<x<<' ';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
10 ms |
348 KB |
Output is correct |
11 |
Correct |
7 ms |
588 KB |
Output is correct |
12 |
Correct |
7 ms |
348 KB |
Output is correct |
13 |
Correct |
5 ms |
348 KB |
Output is correct |
14 |
Correct |
6 ms |
344 KB |
Output is correct |
15 |
Correct |
6 ms |
348 KB |
Output is correct |
16 |
Correct |
6 ms |
588 KB |
Output is correct |
17 |
Correct |
3 ms |
348 KB |
Output is correct |
18 |
Correct |
4 ms |
348 KB |
Output is correct |
19 |
Correct |
5 ms |
348 KB |
Output is correct |
20 |
Correct |
6 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
10 ms |
348 KB |
Output is correct |
11 |
Correct |
7 ms |
588 KB |
Output is correct |
12 |
Correct |
7 ms |
348 KB |
Output is correct |
13 |
Correct |
5 ms |
348 KB |
Output is correct |
14 |
Correct |
6 ms |
344 KB |
Output is correct |
15 |
Correct |
6 ms |
348 KB |
Output is correct |
16 |
Correct |
6 ms |
588 KB |
Output is correct |
17 |
Correct |
3 ms |
348 KB |
Output is correct |
18 |
Correct |
4 ms |
348 KB |
Output is correct |
19 |
Correct |
5 ms |
348 KB |
Output is correct |
20 |
Correct |
6 ms |
596 KB |
Output is correct |
21 |
Correct |
27 ms |
596 KB |
Output is correct |
22 |
Correct |
40 ms |
596 KB |
Output is correct |
23 |
Correct |
16 ms |
600 KB |
Output is correct |
24 |
Correct |
56 ms |
604 KB |
Output is correct |
25 |
Correct |
54 ms |
604 KB |
Output is correct |
26 |
Correct |
63 ms |
624 KB |
Output is correct |
27 |
Correct |
60 ms |
604 KB |
Output is correct |
28 |
Correct |
62 ms |
600 KB |
Output is correct |
29 |
Correct |
65 ms |
620 KB |
Output is correct |
30 |
Correct |
62 ms |
604 KB |
Output is correct |
31 |
Correct |
64 ms |
604 KB |
Output is correct |
32 |
Correct |
62 ms |
600 KB |
Output is correct |
33 |
Correct |
60 ms |
604 KB |
Output is correct |
34 |
Correct |
62 ms |
600 KB |
Output is correct |
35 |
Correct |
63 ms |
604 KB |
Output is correct |
36 |
Correct |
62 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
10 ms |
348 KB |
Output is correct |
11 |
Correct |
7 ms |
588 KB |
Output is correct |
12 |
Correct |
7 ms |
348 KB |
Output is correct |
13 |
Correct |
5 ms |
348 KB |
Output is correct |
14 |
Correct |
6 ms |
344 KB |
Output is correct |
15 |
Correct |
6 ms |
348 KB |
Output is correct |
16 |
Correct |
6 ms |
588 KB |
Output is correct |
17 |
Correct |
3 ms |
348 KB |
Output is correct |
18 |
Correct |
4 ms |
348 KB |
Output is correct |
19 |
Correct |
5 ms |
348 KB |
Output is correct |
20 |
Correct |
6 ms |
596 KB |
Output is correct |
21 |
Correct |
27 ms |
596 KB |
Output is correct |
22 |
Correct |
40 ms |
596 KB |
Output is correct |
23 |
Correct |
16 ms |
600 KB |
Output is correct |
24 |
Correct |
56 ms |
604 KB |
Output is correct |
25 |
Correct |
54 ms |
604 KB |
Output is correct |
26 |
Correct |
63 ms |
624 KB |
Output is correct |
27 |
Correct |
60 ms |
604 KB |
Output is correct |
28 |
Correct |
62 ms |
600 KB |
Output is correct |
29 |
Correct |
65 ms |
620 KB |
Output is correct |
30 |
Correct |
62 ms |
604 KB |
Output is correct |
31 |
Correct |
64 ms |
604 KB |
Output is correct |
32 |
Correct |
62 ms |
600 KB |
Output is correct |
33 |
Correct |
60 ms |
604 KB |
Output is correct |
34 |
Correct |
62 ms |
600 KB |
Output is correct |
35 |
Correct |
63 ms |
604 KB |
Output is correct |
36 |
Correct |
62 ms |
604 KB |
Output is correct |
37 |
Correct |
244 ms |
1104 KB |
Output is correct |
38 |
Correct |
245 ms |
1172 KB |
Output is correct |
39 |
Correct |
372 ms |
604 KB |
Output is correct |
40 |
Correct |
471 ms |
1464 KB |
Output is correct |
41 |
Correct |
434 ms |
856 KB |
Output is correct |
42 |
Correct |
377 ms |
1364 KB |
Output is correct |
43 |
Correct |
363 ms |
2068 KB |
Output is correct |
44 |
Correct |
378 ms |
2128 KB |
Output is correct |
45 |
Correct |
385 ms |
2076 KB |
Output is correct |
46 |
Correct |
457 ms |
692 KB |
Output is correct |
47 |
Correct |
378 ms |
1464 KB |
Output is correct |
48 |
Correct |
403 ms |
1620 KB |
Output is correct |
49 |
Correct |
391 ms |
812 KB |
Output is correct |
50 |
Correct |
381 ms |
1624 KB |
Output is correct |
51 |
Correct |
403 ms |
852 KB |
Output is correct |
52 |
Correct |
450 ms |
2128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
10 ms |
348 KB |
Output is correct |
11 |
Correct |
7 ms |
588 KB |
Output is correct |
12 |
Correct |
7 ms |
348 KB |
Output is correct |
13 |
Correct |
5 ms |
348 KB |
Output is correct |
14 |
Correct |
6 ms |
344 KB |
Output is correct |
15 |
Correct |
6 ms |
348 KB |
Output is correct |
16 |
Correct |
6 ms |
588 KB |
Output is correct |
17 |
Correct |
3 ms |
348 KB |
Output is correct |
18 |
Correct |
4 ms |
348 KB |
Output is correct |
19 |
Correct |
5 ms |
348 KB |
Output is correct |
20 |
Correct |
6 ms |
596 KB |
Output is correct |
21 |
Correct |
27 ms |
596 KB |
Output is correct |
22 |
Correct |
40 ms |
596 KB |
Output is correct |
23 |
Correct |
16 ms |
600 KB |
Output is correct |
24 |
Correct |
56 ms |
604 KB |
Output is correct |
25 |
Correct |
54 ms |
604 KB |
Output is correct |
26 |
Correct |
63 ms |
624 KB |
Output is correct |
27 |
Correct |
60 ms |
604 KB |
Output is correct |
28 |
Correct |
62 ms |
600 KB |
Output is correct |
29 |
Correct |
65 ms |
620 KB |
Output is correct |
30 |
Correct |
62 ms |
604 KB |
Output is correct |
31 |
Correct |
64 ms |
604 KB |
Output is correct |
32 |
Correct |
62 ms |
600 KB |
Output is correct |
33 |
Correct |
60 ms |
604 KB |
Output is correct |
34 |
Correct |
62 ms |
600 KB |
Output is correct |
35 |
Correct |
63 ms |
604 KB |
Output is correct |
36 |
Correct |
62 ms |
604 KB |
Output is correct |
37 |
Correct |
244 ms |
1104 KB |
Output is correct |
38 |
Correct |
245 ms |
1172 KB |
Output is correct |
39 |
Correct |
372 ms |
604 KB |
Output is correct |
40 |
Correct |
471 ms |
1464 KB |
Output is correct |
41 |
Correct |
434 ms |
856 KB |
Output is correct |
42 |
Correct |
377 ms |
1364 KB |
Output is correct |
43 |
Correct |
363 ms |
2068 KB |
Output is correct |
44 |
Correct |
378 ms |
2128 KB |
Output is correct |
45 |
Correct |
385 ms |
2076 KB |
Output is correct |
46 |
Correct |
457 ms |
692 KB |
Output is correct |
47 |
Correct |
378 ms |
1464 KB |
Output is correct |
48 |
Correct |
403 ms |
1620 KB |
Output is correct |
49 |
Correct |
391 ms |
812 KB |
Output is correct |
50 |
Correct |
381 ms |
1624 KB |
Output is correct |
51 |
Correct |
403 ms |
852 KB |
Output is correct |
52 |
Correct |
450 ms |
2128 KB |
Output is correct |
53 |
Correct |
562 ms |
1772 KB |
Output is correct |
54 |
Correct |
763 ms |
2068 KB |
Output is correct |
55 |
Correct |
757 ms |
3664 KB |
Output is correct |
56 |
Correct |
564 ms |
2132 KB |
Output is correct |
57 |
Correct |
739 ms |
3664 KB |
Output is correct |
58 |
Correct |
757 ms |
2388 KB |
Output is correct |
59 |
Correct |
771 ms |
2668 KB |
Output is correct |
60 |
Correct |
770 ms |
848 KB |
Output is correct |
61 |
Correct |
768 ms |
3152 KB |
Output is correct |
62 |
Correct |
640 ms |
3248 KB |
Output is correct |
63 |
Correct |
638 ms |
3516 KB |
Output is correct |
64 |
Correct |
625 ms |
3408 KB |
Output is correct |
65 |
Correct |
605 ms |
756 KB |
Output is correct |
66 |
Correct |
580 ms |
1108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
10 ms |
348 KB |
Output is correct |
11 |
Correct |
7 ms |
588 KB |
Output is correct |
12 |
Correct |
7 ms |
348 KB |
Output is correct |
13 |
Correct |
5 ms |
348 KB |
Output is correct |
14 |
Correct |
6 ms |
344 KB |
Output is correct |
15 |
Correct |
6 ms |
348 KB |
Output is correct |
16 |
Correct |
6 ms |
588 KB |
Output is correct |
17 |
Correct |
3 ms |
348 KB |
Output is correct |
18 |
Correct |
4 ms |
348 KB |
Output is correct |
19 |
Correct |
5 ms |
348 KB |
Output is correct |
20 |
Correct |
6 ms |
596 KB |
Output is correct |
21 |
Correct |
27 ms |
596 KB |
Output is correct |
22 |
Correct |
40 ms |
596 KB |
Output is correct |
23 |
Correct |
16 ms |
600 KB |
Output is correct |
24 |
Correct |
56 ms |
604 KB |
Output is correct |
25 |
Correct |
54 ms |
604 KB |
Output is correct |
26 |
Correct |
63 ms |
624 KB |
Output is correct |
27 |
Correct |
60 ms |
604 KB |
Output is correct |
28 |
Correct |
62 ms |
600 KB |
Output is correct |
29 |
Correct |
65 ms |
620 KB |
Output is correct |
30 |
Correct |
62 ms |
604 KB |
Output is correct |
31 |
Correct |
64 ms |
604 KB |
Output is correct |
32 |
Correct |
62 ms |
600 KB |
Output is correct |
33 |
Correct |
60 ms |
604 KB |
Output is correct |
34 |
Correct |
62 ms |
600 KB |
Output is correct |
35 |
Correct |
63 ms |
604 KB |
Output is correct |
36 |
Correct |
62 ms |
604 KB |
Output is correct |
37 |
Correct |
244 ms |
1104 KB |
Output is correct |
38 |
Correct |
245 ms |
1172 KB |
Output is correct |
39 |
Correct |
372 ms |
604 KB |
Output is correct |
40 |
Correct |
471 ms |
1464 KB |
Output is correct |
41 |
Correct |
434 ms |
856 KB |
Output is correct |
42 |
Correct |
377 ms |
1364 KB |
Output is correct |
43 |
Correct |
363 ms |
2068 KB |
Output is correct |
44 |
Correct |
378 ms |
2128 KB |
Output is correct |
45 |
Correct |
385 ms |
2076 KB |
Output is correct |
46 |
Correct |
457 ms |
692 KB |
Output is correct |
47 |
Correct |
378 ms |
1464 KB |
Output is correct |
48 |
Correct |
403 ms |
1620 KB |
Output is correct |
49 |
Correct |
391 ms |
812 KB |
Output is correct |
50 |
Correct |
381 ms |
1624 KB |
Output is correct |
51 |
Correct |
403 ms |
852 KB |
Output is correct |
52 |
Correct |
450 ms |
2128 KB |
Output is correct |
53 |
Correct |
562 ms |
1772 KB |
Output is correct |
54 |
Correct |
763 ms |
2068 KB |
Output is correct |
55 |
Correct |
757 ms |
3664 KB |
Output is correct |
56 |
Correct |
564 ms |
2132 KB |
Output is correct |
57 |
Correct |
739 ms |
3664 KB |
Output is correct |
58 |
Correct |
757 ms |
2388 KB |
Output is correct |
59 |
Correct |
771 ms |
2668 KB |
Output is correct |
60 |
Correct |
770 ms |
848 KB |
Output is correct |
61 |
Correct |
768 ms |
3152 KB |
Output is correct |
62 |
Correct |
640 ms |
3248 KB |
Output is correct |
63 |
Correct |
638 ms |
3516 KB |
Output is correct |
64 |
Correct |
625 ms |
3408 KB |
Output is correct |
65 |
Correct |
605 ms |
756 KB |
Output is correct |
66 |
Correct |
580 ms |
1108 KB |
Output is correct |
67 |
Correct |
998 ms |
3152 KB |
Output is correct |
68 |
Correct |
3 ms |
348 KB |
Output is correct |
69 |
Execution timed out |
1084 ms |
1360 KB |
Time limit exceeded |
70 |
Halted |
0 ms |
0 KB |
- |