#include <bits/stdc++.h>
using namespace std;
bitset<125005> dp;
int v[505], sepoate[250005];
int main()
{
int n, sum = 0;
cin>>n;
dp[0] = 1;
for(int i = 1; i <= n; i++)
{
cin>>v[i], sum += v[i];
dp = ((dp << v[i]) | dp);
}
if(sum % 2 == 1 || dp[sum / 2] == 0)
{
cout<<0;
return 0;
}
for(int i = 1; i <= n; i++)
{
dp.reset();
sum -= v[i];
dp[0] = 1;
for(int j = 1; j <= n; j++)
{
if(j == i) continue;
dp |= (dp << v[j]);
}
for(int j = 0; j <= sum && j * 2 <= sum; j++)
if(dp[j] == 1)
sepoate[sum - 2 * j]++;
sum += v[i];
}
int rez = 0;
vector<int> aux;
for(int i = 0; i <= sum; i++)
if(sepoate[i] == n)
rez++, aux.push_back(i);
cout<<rez<<'\n';
for(auto it : aux) cout<<it<<" ";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
348 KB |
Output is correct |
11 |
Correct |
3 ms |
348 KB |
Output is correct |
12 |
Correct |
3 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
4 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
2 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
3 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
348 KB |
Output is correct |
11 |
Correct |
3 ms |
348 KB |
Output is correct |
12 |
Correct |
3 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
4 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
2 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
3 ms |
344 KB |
Output is correct |
21 |
Correct |
12 ms |
496 KB |
Output is correct |
22 |
Correct |
15 ms |
348 KB |
Output is correct |
23 |
Correct |
7 ms |
496 KB |
Output is correct |
24 |
Correct |
25 ms |
348 KB |
Output is correct |
25 |
Correct |
25 ms |
520 KB |
Output is correct |
26 |
Correct |
28 ms |
496 KB |
Output is correct |
27 |
Correct |
28 ms |
348 KB |
Output is correct |
28 |
Correct |
30 ms |
508 KB |
Output is correct |
29 |
Correct |
28 ms |
344 KB |
Output is correct |
30 |
Correct |
28 ms |
348 KB |
Output is correct |
31 |
Correct |
28 ms |
508 KB |
Output is correct |
32 |
Correct |
28 ms |
344 KB |
Output is correct |
33 |
Correct |
28 ms |
348 KB |
Output is correct |
34 |
Correct |
27 ms |
496 KB |
Output is correct |
35 |
Correct |
28 ms |
344 KB |
Output is correct |
36 |
Correct |
36 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
348 KB |
Output is correct |
11 |
Correct |
3 ms |
348 KB |
Output is correct |
12 |
Correct |
3 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
4 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
2 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
3 ms |
344 KB |
Output is correct |
21 |
Correct |
12 ms |
496 KB |
Output is correct |
22 |
Correct |
15 ms |
348 KB |
Output is correct |
23 |
Correct |
7 ms |
496 KB |
Output is correct |
24 |
Correct |
25 ms |
348 KB |
Output is correct |
25 |
Correct |
25 ms |
520 KB |
Output is correct |
26 |
Correct |
28 ms |
496 KB |
Output is correct |
27 |
Correct |
28 ms |
348 KB |
Output is correct |
28 |
Correct |
30 ms |
508 KB |
Output is correct |
29 |
Correct |
28 ms |
344 KB |
Output is correct |
30 |
Correct |
28 ms |
348 KB |
Output is correct |
31 |
Correct |
28 ms |
508 KB |
Output is correct |
32 |
Correct |
28 ms |
344 KB |
Output is correct |
33 |
Correct |
28 ms |
348 KB |
Output is correct |
34 |
Correct |
27 ms |
496 KB |
Output is correct |
35 |
Correct |
28 ms |
344 KB |
Output is correct |
36 |
Correct |
36 ms |
492 KB |
Output is correct |
37 |
Correct |
112 ms |
540 KB |
Output is correct |
38 |
Correct |
124 ms |
536 KB |
Output is correct |
39 |
Correct |
179 ms |
604 KB |
Output is correct |
40 |
Correct |
204 ms |
600 KB |
Output is correct |
41 |
Correct |
212 ms |
604 KB |
Output is correct |
42 |
Correct |
176 ms |
592 KB |
Output is correct |
43 |
Correct |
173 ms |
848 KB |
Output is correct |
44 |
Correct |
176 ms |
856 KB |
Output is correct |
45 |
Correct |
184 ms |
940 KB |
Output is correct |
46 |
Correct |
202 ms |
600 KB |
Output is correct |
47 |
Correct |
178 ms |
600 KB |
Output is correct |
48 |
Correct |
180 ms |
952 KB |
Output is correct |
49 |
Correct |
184 ms |
700 KB |
Output is correct |
50 |
Correct |
175 ms |
604 KB |
Output is correct |
51 |
Correct |
1 ms |
348 KB |
Output is correct |
52 |
Correct |
213 ms |
1004 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
348 KB |
Output is correct |
11 |
Correct |
3 ms |
348 KB |
Output is correct |
12 |
Correct |
3 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
4 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
2 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
3 ms |
344 KB |
Output is correct |
21 |
Correct |
12 ms |
496 KB |
Output is correct |
22 |
Correct |
15 ms |
348 KB |
Output is correct |
23 |
Correct |
7 ms |
496 KB |
Output is correct |
24 |
Correct |
25 ms |
348 KB |
Output is correct |
25 |
Correct |
25 ms |
520 KB |
Output is correct |
26 |
Correct |
28 ms |
496 KB |
Output is correct |
27 |
Correct |
28 ms |
348 KB |
Output is correct |
28 |
Correct |
30 ms |
508 KB |
Output is correct |
29 |
Correct |
28 ms |
344 KB |
Output is correct |
30 |
Correct |
28 ms |
348 KB |
Output is correct |
31 |
Correct |
28 ms |
508 KB |
Output is correct |
32 |
Correct |
28 ms |
344 KB |
Output is correct |
33 |
Correct |
28 ms |
348 KB |
Output is correct |
34 |
Correct |
27 ms |
496 KB |
Output is correct |
35 |
Correct |
28 ms |
344 KB |
Output is correct |
36 |
Correct |
36 ms |
492 KB |
Output is correct |
37 |
Correct |
112 ms |
540 KB |
Output is correct |
38 |
Correct |
124 ms |
536 KB |
Output is correct |
39 |
Correct |
179 ms |
604 KB |
Output is correct |
40 |
Correct |
204 ms |
600 KB |
Output is correct |
41 |
Correct |
212 ms |
604 KB |
Output is correct |
42 |
Correct |
176 ms |
592 KB |
Output is correct |
43 |
Correct |
173 ms |
848 KB |
Output is correct |
44 |
Correct |
176 ms |
856 KB |
Output is correct |
45 |
Correct |
184 ms |
940 KB |
Output is correct |
46 |
Correct |
202 ms |
600 KB |
Output is correct |
47 |
Correct |
178 ms |
600 KB |
Output is correct |
48 |
Correct |
180 ms |
952 KB |
Output is correct |
49 |
Correct |
184 ms |
700 KB |
Output is correct |
50 |
Correct |
175 ms |
604 KB |
Output is correct |
51 |
Correct |
1 ms |
348 KB |
Output is correct |
52 |
Correct |
213 ms |
1004 KB |
Output is correct |
53 |
Correct |
259 ms |
896 KB |
Output is correct |
54 |
Correct |
352 ms |
940 KB |
Output is correct |
55 |
Correct |
355 ms |
1276 KB |
Output is correct |
56 |
Correct |
262 ms |
852 KB |
Output is correct |
57 |
Correct |
364 ms |
1740 KB |
Output is correct |
58 |
Correct |
355 ms |
1108 KB |
Output is correct |
59 |
Correct |
357 ms |
1156 KB |
Output is correct |
60 |
Correct |
1 ms |
348 KB |
Output is correct |
61 |
Correct |
355 ms |
1188 KB |
Output is correct |
62 |
Correct |
310 ms |
1232 KB |
Output is correct |
63 |
Correct |
295 ms |
1244 KB |
Output is correct |
64 |
Correct |
296 ms |
1228 KB |
Output is correct |
65 |
Correct |
277 ms |
648 KB |
Output is correct |
66 |
Correct |
285 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
348 KB |
Output is correct |
11 |
Correct |
3 ms |
348 KB |
Output is correct |
12 |
Correct |
3 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
4 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
2 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
3 ms |
344 KB |
Output is correct |
21 |
Correct |
12 ms |
496 KB |
Output is correct |
22 |
Correct |
15 ms |
348 KB |
Output is correct |
23 |
Correct |
7 ms |
496 KB |
Output is correct |
24 |
Correct |
25 ms |
348 KB |
Output is correct |
25 |
Correct |
25 ms |
520 KB |
Output is correct |
26 |
Correct |
28 ms |
496 KB |
Output is correct |
27 |
Correct |
28 ms |
348 KB |
Output is correct |
28 |
Correct |
30 ms |
508 KB |
Output is correct |
29 |
Correct |
28 ms |
344 KB |
Output is correct |
30 |
Correct |
28 ms |
348 KB |
Output is correct |
31 |
Correct |
28 ms |
508 KB |
Output is correct |
32 |
Correct |
28 ms |
344 KB |
Output is correct |
33 |
Correct |
28 ms |
348 KB |
Output is correct |
34 |
Correct |
27 ms |
496 KB |
Output is correct |
35 |
Correct |
28 ms |
344 KB |
Output is correct |
36 |
Correct |
36 ms |
492 KB |
Output is correct |
37 |
Correct |
112 ms |
540 KB |
Output is correct |
38 |
Correct |
124 ms |
536 KB |
Output is correct |
39 |
Correct |
179 ms |
604 KB |
Output is correct |
40 |
Correct |
204 ms |
600 KB |
Output is correct |
41 |
Correct |
212 ms |
604 KB |
Output is correct |
42 |
Correct |
176 ms |
592 KB |
Output is correct |
43 |
Correct |
173 ms |
848 KB |
Output is correct |
44 |
Correct |
176 ms |
856 KB |
Output is correct |
45 |
Correct |
184 ms |
940 KB |
Output is correct |
46 |
Correct |
202 ms |
600 KB |
Output is correct |
47 |
Correct |
178 ms |
600 KB |
Output is correct |
48 |
Correct |
180 ms |
952 KB |
Output is correct |
49 |
Correct |
184 ms |
700 KB |
Output is correct |
50 |
Correct |
175 ms |
604 KB |
Output is correct |
51 |
Correct |
1 ms |
348 KB |
Output is correct |
52 |
Correct |
213 ms |
1004 KB |
Output is correct |
53 |
Correct |
259 ms |
896 KB |
Output is correct |
54 |
Correct |
352 ms |
940 KB |
Output is correct |
55 |
Correct |
355 ms |
1276 KB |
Output is correct |
56 |
Correct |
262 ms |
852 KB |
Output is correct |
57 |
Correct |
364 ms |
1740 KB |
Output is correct |
58 |
Correct |
355 ms |
1108 KB |
Output is correct |
59 |
Correct |
357 ms |
1156 KB |
Output is correct |
60 |
Correct |
1 ms |
348 KB |
Output is correct |
61 |
Correct |
355 ms |
1188 KB |
Output is correct |
62 |
Correct |
310 ms |
1232 KB |
Output is correct |
63 |
Correct |
295 ms |
1244 KB |
Output is correct |
64 |
Correct |
296 ms |
1228 KB |
Output is correct |
65 |
Correct |
277 ms |
648 KB |
Output is correct |
66 |
Correct |
285 ms |
604 KB |
Output is correct |
67 |
Correct |
463 ms |
1156 KB |
Output is correct |
68 |
Correct |
2 ms |
344 KB |
Output is correct |
69 |
Correct |
761 ms |
2436 KB |
Output is correct |
70 |
Correct |
738 ms |
1740 KB |
Output is correct |
71 |
Correct |
726 ms |
1584 KB |
Output is correct |
72 |
Correct |
706 ms |
948 KB |
Output is correct |
73 |
Correct |
728 ms |
948 KB |
Output is correct |
74 |
Correct |
751 ms |
2412 KB |
Output is correct |
75 |
Correct |
764 ms |
2032 KB |
Output is correct |
76 |
Correct |
764 ms |
2560 KB |
Output is correct |
77 |
Correct |
757 ms |
2532 KB |
Output is correct |