#include <bits/stdc++.h>
using namespace std;
const int MAXN = 502;
int g[MAXN*MAXN];
int ar[MAXN];
int n;
bitset<MAXN * MAXN> kp;
vector<int> obtainable;
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: obtainable){
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];
}
for (int i=0; i<MAXN*MAXN; i++){
if (kp[i]) obtainable.push_back(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 |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
3 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 |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
3 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
8 ms |
348 KB |
Output is correct |
11 |
Correct |
7 ms |
604 KB |
Output is correct |
12 |
Correct |
8 ms |
348 KB |
Output is correct |
13 |
Correct |
6 ms |
348 KB |
Output is correct |
14 |
Correct |
6 ms |
604 KB |
Output is correct |
15 |
Correct |
7 ms |
348 KB |
Output is correct |
16 |
Correct |
7 ms |
532 KB |
Output is correct |
17 |
Correct |
4 ms |
348 KB |
Output is correct |
18 |
Correct |
6 ms |
592 KB |
Output is correct |
19 |
Correct |
6 ms |
604 KB |
Output is correct |
20 |
Correct |
9 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
3 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
8 ms |
348 KB |
Output is correct |
11 |
Correct |
7 ms |
604 KB |
Output is correct |
12 |
Correct |
8 ms |
348 KB |
Output is correct |
13 |
Correct |
6 ms |
348 KB |
Output is correct |
14 |
Correct |
6 ms |
604 KB |
Output is correct |
15 |
Correct |
7 ms |
348 KB |
Output is correct |
16 |
Correct |
7 ms |
532 KB |
Output is correct |
17 |
Correct |
4 ms |
348 KB |
Output is correct |
18 |
Correct |
6 ms |
592 KB |
Output is correct |
19 |
Correct |
6 ms |
604 KB |
Output is correct |
20 |
Correct |
9 ms |
348 KB |
Output is correct |
21 |
Correct |
29 ms |
624 KB |
Output is correct |
22 |
Correct |
38 ms |
612 KB |
Output is correct |
23 |
Correct |
18 ms |
600 KB |
Output is correct |
24 |
Correct |
60 ms |
600 KB |
Output is correct |
25 |
Correct |
62 ms |
600 KB |
Output is correct |
26 |
Correct |
68 ms |
600 KB |
Output is correct |
27 |
Correct |
71 ms |
604 KB |
Output is correct |
28 |
Correct |
75 ms |
604 KB |
Output is correct |
29 |
Correct |
67 ms |
604 KB |
Output is correct |
30 |
Correct |
73 ms |
644 KB |
Output is correct |
31 |
Correct |
69 ms |
660 KB |
Output is correct |
32 |
Correct |
69 ms |
604 KB |
Output is correct |
33 |
Correct |
68 ms |
604 KB |
Output is correct |
34 |
Correct |
68 ms |
608 KB |
Output is correct |
35 |
Correct |
68 ms |
636 KB |
Output is correct |
36 |
Correct |
68 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
3 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
8 ms |
348 KB |
Output is correct |
11 |
Correct |
7 ms |
604 KB |
Output is correct |
12 |
Correct |
8 ms |
348 KB |
Output is correct |
13 |
Correct |
6 ms |
348 KB |
Output is correct |
14 |
Correct |
6 ms |
604 KB |
Output is correct |
15 |
Correct |
7 ms |
348 KB |
Output is correct |
16 |
Correct |
7 ms |
532 KB |
Output is correct |
17 |
Correct |
4 ms |
348 KB |
Output is correct |
18 |
Correct |
6 ms |
592 KB |
Output is correct |
19 |
Correct |
6 ms |
604 KB |
Output is correct |
20 |
Correct |
9 ms |
348 KB |
Output is correct |
21 |
Correct |
29 ms |
624 KB |
Output is correct |
22 |
Correct |
38 ms |
612 KB |
Output is correct |
23 |
Correct |
18 ms |
600 KB |
Output is correct |
24 |
Correct |
60 ms |
600 KB |
Output is correct |
25 |
Correct |
62 ms |
600 KB |
Output is correct |
26 |
Correct |
68 ms |
600 KB |
Output is correct |
27 |
Correct |
71 ms |
604 KB |
Output is correct |
28 |
Correct |
75 ms |
604 KB |
Output is correct |
29 |
Correct |
67 ms |
604 KB |
Output is correct |
30 |
Correct |
73 ms |
644 KB |
Output is correct |
31 |
Correct |
69 ms |
660 KB |
Output is correct |
32 |
Correct |
69 ms |
604 KB |
Output is correct |
33 |
Correct |
68 ms |
604 KB |
Output is correct |
34 |
Correct |
68 ms |
608 KB |
Output is correct |
35 |
Correct |
68 ms |
636 KB |
Output is correct |
36 |
Correct |
68 ms |
600 KB |
Output is correct |
37 |
Correct |
282 ms |
1104 KB |
Output is correct |
38 |
Correct |
284 ms |
1116 KB |
Output is correct |
39 |
Correct |
406 ms |
600 KB |
Output is correct |
40 |
Correct |
510 ms |
1728 KB |
Output is correct |
41 |
Correct |
531 ms |
1108 KB |
Output is correct |
42 |
Correct |
421 ms |
1460 KB |
Output is correct |
43 |
Correct |
413 ms |
2256 KB |
Output is correct |
44 |
Correct |
421 ms |
2168 KB |
Output is correct |
45 |
Correct |
450 ms |
2164 KB |
Output is correct |
46 |
Correct |
513 ms |
848 KB |
Output is correct |
47 |
Correct |
446 ms |
1476 KB |
Output is correct |
48 |
Correct |
440 ms |
1904 KB |
Output is correct |
49 |
Correct |
428 ms |
1080 KB |
Output is correct |
50 |
Correct |
428 ms |
1496 KB |
Output is correct |
51 |
Correct |
420 ms |
860 KB |
Output is correct |
52 |
Correct |
549 ms |
2504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
3 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
8 ms |
348 KB |
Output is correct |
11 |
Correct |
7 ms |
604 KB |
Output is correct |
12 |
Correct |
8 ms |
348 KB |
Output is correct |
13 |
Correct |
6 ms |
348 KB |
Output is correct |
14 |
Correct |
6 ms |
604 KB |
Output is correct |
15 |
Correct |
7 ms |
348 KB |
Output is correct |
16 |
Correct |
7 ms |
532 KB |
Output is correct |
17 |
Correct |
4 ms |
348 KB |
Output is correct |
18 |
Correct |
6 ms |
592 KB |
Output is correct |
19 |
Correct |
6 ms |
604 KB |
Output is correct |
20 |
Correct |
9 ms |
348 KB |
Output is correct |
21 |
Correct |
29 ms |
624 KB |
Output is correct |
22 |
Correct |
38 ms |
612 KB |
Output is correct |
23 |
Correct |
18 ms |
600 KB |
Output is correct |
24 |
Correct |
60 ms |
600 KB |
Output is correct |
25 |
Correct |
62 ms |
600 KB |
Output is correct |
26 |
Correct |
68 ms |
600 KB |
Output is correct |
27 |
Correct |
71 ms |
604 KB |
Output is correct |
28 |
Correct |
75 ms |
604 KB |
Output is correct |
29 |
Correct |
67 ms |
604 KB |
Output is correct |
30 |
Correct |
73 ms |
644 KB |
Output is correct |
31 |
Correct |
69 ms |
660 KB |
Output is correct |
32 |
Correct |
69 ms |
604 KB |
Output is correct |
33 |
Correct |
68 ms |
604 KB |
Output is correct |
34 |
Correct |
68 ms |
608 KB |
Output is correct |
35 |
Correct |
68 ms |
636 KB |
Output is correct |
36 |
Correct |
68 ms |
600 KB |
Output is correct |
37 |
Correct |
282 ms |
1104 KB |
Output is correct |
38 |
Correct |
284 ms |
1116 KB |
Output is correct |
39 |
Correct |
406 ms |
600 KB |
Output is correct |
40 |
Correct |
510 ms |
1728 KB |
Output is correct |
41 |
Correct |
531 ms |
1108 KB |
Output is correct |
42 |
Correct |
421 ms |
1460 KB |
Output is correct |
43 |
Correct |
413 ms |
2256 KB |
Output is correct |
44 |
Correct |
421 ms |
2168 KB |
Output is correct |
45 |
Correct |
450 ms |
2164 KB |
Output is correct |
46 |
Correct |
513 ms |
848 KB |
Output is correct |
47 |
Correct |
446 ms |
1476 KB |
Output is correct |
48 |
Correct |
440 ms |
1904 KB |
Output is correct |
49 |
Correct |
428 ms |
1080 KB |
Output is correct |
50 |
Correct |
428 ms |
1496 KB |
Output is correct |
51 |
Correct |
420 ms |
860 KB |
Output is correct |
52 |
Correct |
549 ms |
2504 KB |
Output is correct |
53 |
Correct |
626 ms |
2092 KB |
Output is correct |
54 |
Correct |
841 ms |
2352 KB |
Output is correct |
55 |
Correct |
861 ms |
3844 KB |
Output is correct |
56 |
Correct |
649 ms |
2428 KB |
Output is correct |
57 |
Correct |
935 ms |
4148 KB |
Output is correct |
58 |
Correct |
887 ms |
2508 KB |
Output is correct |
59 |
Correct |
854 ms |
3104 KB |
Output is correct |
60 |
Correct |
855 ms |
980 KB |
Output is correct |
61 |
Correct |
895 ms |
3428 KB |
Output is correct |
62 |
Correct |
729 ms |
3752 KB |
Output is correct |
63 |
Correct |
764 ms |
3808 KB |
Output is correct |
64 |
Correct |
691 ms |
3792 KB |
Output is correct |
65 |
Correct |
670 ms |
848 KB |
Output is correct |
66 |
Correct |
657 ms |
880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
3 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
8 ms |
348 KB |
Output is correct |
11 |
Correct |
7 ms |
604 KB |
Output is correct |
12 |
Correct |
8 ms |
348 KB |
Output is correct |
13 |
Correct |
6 ms |
348 KB |
Output is correct |
14 |
Correct |
6 ms |
604 KB |
Output is correct |
15 |
Correct |
7 ms |
348 KB |
Output is correct |
16 |
Correct |
7 ms |
532 KB |
Output is correct |
17 |
Correct |
4 ms |
348 KB |
Output is correct |
18 |
Correct |
6 ms |
592 KB |
Output is correct |
19 |
Correct |
6 ms |
604 KB |
Output is correct |
20 |
Correct |
9 ms |
348 KB |
Output is correct |
21 |
Correct |
29 ms |
624 KB |
Output is correct |
22 |
Correct |
38 ms |
612 KB |
Output is correct |
23 |
Correct |
18 ms |
600 KB |
Output is correct |
24 |
Correct |
60 ms |
600 KB |
Output is correct |
25 |
Correct |
62 ms |
600 KB |
Output is correct |
26 |
Correct |
68 ms |
600 KB |
Output is correct |
27 |
Correct |
71 ms |
604 KB |
Output is correct |
28 |
Correct |
75 ms |
604 KB |
Output is correct |
29 |
Correct |
67 ms |
604 KB |
Output is correct |
30 |
Correct |
73 ms |
644 KB |
Output is correct |
31 |
Correct |
69 ms |
660 KB |
Output is correct |
32 |
Correct |
69 ms |
604 KB |
Output is correct |
33 |
Correct |
68 ms |
604 KB |
Output is correct |
34 |
Correct |
68 ms |
608 KB |
Output is correct |
35 |
Correct |
68 ms |
636 KB |
Output is correct |
36 |
Correct |
68 ms |
600 KB |
Output is correct |
37 |
Correct |
282 ms |
1104 KB |
Output is correct |
38 |
Correct |
284 ms |
1116 KB |
Output is correct |
39 |
Correct |
406 ms |
600 KB |
Output is correct |
40 |
Correct |
510 ms |
1728 KB |
Output is correct |
41 |
Correct |
531 ms |
1108 KB |
Output is correct |
42 |
Correct |
421 ms |
1460 KB |
Output is correct |
43 |
Correct |
413 ms |
2256 KB |
Output is correct |
44 |
Correct |
421 ms |
2168 KB |
Output is correct |
45 |
Correct |
450 ms |
2164 KB |
Output is correct |
46 |
Correct |
513 ms |
848 KB |
Output is correct |
47 |
Correct |
446 ms |
1476 KB |
Output is correct |
48 |
Correct |
440 ms |
1904 KB |
Output is correct |
49 |
Correct |
428 ms |
1080 KB |
Output is correct |
50 |
Correct |
428 ms |
1496 KB |
Output is correct |
51 |
Correct |
420 ms |
860 KB |
Output is correct |
52 |
Correct |
549 ms |
2504 KB |
Output is correct |
53 |
Correct |
626 ms |
2092 KB |
Output is correct |
54 |
Correct |
841 ms |
2352 KB |
Output is correct |
55 |
Correct |
861 ms |
3844 KB |
Output is correct |
56 |
Correct |
649 ms |
2428 KB |
Output is correct |
57 |
Correct |
935 ms |
4148 KB |
Output is correct |
58 |
Correct |
887 ms |
2508 KB |
Output is correct |
59 |
Correct |
854 ms |
3104 KB |
Output is correct |
60 |
Correct |
855 ms |
980 KB |
Output is correct |
61 |
Correct |
895 ms |
3428 KB |
Output is correct |
62 |
Correct |
729 ms |
3752 KB |
Output is correct |
63 |
Correct |
764 ms |
3808 KB |
Output is correct |
64 |
Correct |
691 ms |
3792 KB |
Output is correct |
65 |
Correct |
670 ms |
848 KB |
Output is correct |
66 |
Correct |
657 ms |
880 KB |
Output is correct |
67 |
Execution timed out |
1038 ms |
1232 KB |
Time limit exceeded |
68 |
Halted |
0 ms |
0 KB |
- |