#include <bits/stdc++.h>
using namespace std;
const int maxN = 500;
const int maxS = 110000;
int v[maxN + 1];
bitset<maxS + 1> pos[maxN + 1];
bitset<maxS + 1> tim, timTemp;
int main() {
int n, s = 0;
cin >> n;
for ( int i = 1; i <= n; i++ )
cin >> v[i], s += v[i];
pos[0][0] = true;
for ( int i = 1; i <= n; i++ )
pos[i] = (pos[i - 1] | (pos[i - 1] << v[i]));
if ( s % 2 != 0 || !pos[n][s / 2] ) {
cout << 0;
return 0;
}
for ( int i = 0; i <= s; i++ )
tim[i] = true;
for ( int r = 1; r <= n; r++ ) {
pos[0][0] = true;
for ( int i = 1; i <= n; i++ ) {
pos[i] = pos[i - 1];
if ( i != r )
pos[i] |= (pos[i - 1] << v[i]);
}
timTemp.reset();
for ( int i = 0; i <= s; i++ ) {
if ( pos[n][i] )
timTemp[abs( s - v[r] - i - i )] = true;
}
tim &= timTemp;
}
tim[0] = false;
cout << tim.count() << "\n";
for ( int i = 0; i <= s; i++ ) {
if ( tim[i] )
cout << i << " ";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
4 ms |
724 KB |
Output is correct |
11 |
Correct |
4 ms |
724 KB |
Output is correct |
12 |
Correct |
4 ms |
724 KB |
Output is correct |
13 |
Correct |
3 ms |
596 KB |
Output is correct |
14 |
Correct |
4 ms |
724 KB |
Output is correct |
15 |
Correct |
3 ms |
724 KB |
Output is correct |
16 |
Correct |
4 ms |
724 KB |
Output is correct |
17 |
Correct |
2 ms |
596 KB |
Output is correct |
18 |
Correct |
3 ms |
596 KB |
Output is correct |
19 |
Correct |
3 ms |
596 KB |
Output is correct |
20 |
Correct |
5 ms |
724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
4 ms |
724 KB |
Output is correct |
11 |
Correct |
4 ms |
724 KB |
Output is correct |
12 |
Correct |
4 ms |
724 KB |
Output is correct |
13 |
Correct |
3 ms |
596 KB |
Output is correct |
14 |
Correct |
4 ms |
724 KB |
Output is correct |
15 |
Correct |
3 ms |
724 KB |
Output is correct |
16 |
Correct |
4 ms |
724 KB |
Output is correct |
17 |
Correct |
2 ms |
596 KB |
Output is correct |
18 |
Correct |
3 ms |
596 KB |
Output is correct |
19 |
Correct |
3 ms |
596 KB |
Output is correct |
20 |
Correct |
5 ms |
724 KB |
Output is correct |
21 |
Correct |
21 ms |
1108 KB |
Output is correct |
22 |
Correct |
22 ms |
1236 KB |
Output is correct |
23 |
Correct |
10 ms |
1032 KB |
Output is correct |
24 |
Correct |
34 ms |
1612 KB |
Output is correct |
25 |
Correct |
39 ms |
1620 KB |
Output is correct |
26 |
Correct |
40 ms |
1692 KB |
Output is correct |
27 |
Correct |
40 ms |
1696 KB |
Output is correct |
28 |
Correct |
40 ms |
1684 KB |
Output is correct |
29 |
Correct |
37 ms |
1620 KB |
Output is correct |
30 |
Correct |
37 ms |
1620 KB |
Output is correct |
31 |
Correct |
38 ms |
1696 KB |
Output is correct |
32 |
Correct |
37 ms |
1688 KB |
Output is correct |
33 |
Correct |
36 ms |
1620 KB |
Output is correct |
34 |
Correct |
44 ms |
1620 KB |
Output is correct |
35 |
Correct |
38 ms |
1620 KB |
Output is correct |
36 |
Correct |
43 ms |
1684 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
4 ms |
724 KB |
Output is correct |
11 |
Correct |
4 ms |
724 KB |
Output is correct |
12 |
Correct |
4 ms |
724 KB |
Output is correct |
13 |
Correct |
3 ms |
596 KB |
Output is correct |
14 |
Correct |
4 ms |
724 KB |
Output is correct |
15 |
Correct |
3 ms |
724 KB |
Output is correct |
16 |
Correct |
4 ms |
724 KB |
Output is correct |
17 |
Correct |
2 ms |
596 KB |
Output is correct |
18 |
Correct |
3 ms |
596 KB |
Output is correct |
19 |
Correct |
3 ms |
596 KB |
Output is correct |
20 |
Correct |
5 ms |
724 KB |
Output is correct |
21 |
Correct |
21 ms |
1108 KB |
Output is correct |
22 |
Correct |
22 ms |
1236 KB |
Output is correct |
23 |
Correct |
10 ms |
1032 KB |
Output is correct |
24 |
Correct |
34 ms |
1612 KB |
Output is correct |
25 |
Correct |
39 ms |
1620 KB |
Output is correct |
26 |
Correct |
40 ms |
1692 KB |
Output is correct |
27 |
Correct |
40 ms |
1696 KB |
Output is correct |
28 |
Correct |
40 ms |
1684 KB |
Output is correct |
29 |
Correct |
37 ms |
1620 KB |
Output is correct |
30 |
Correct |
37 ms |
1620 KB |
Output is correct |
31 |
Correct |
38 ms |
1696 KB |
Output is correct |
32 |
Correct |
37 ms |
1688 KB |
Output is correct |
33 |
Correct |
36 ms |
1620 KB |
Output is correct |
34 |
Correct |
44 ms |
1620 KB |
Output is correct |
35 |
Correct |
38 ms |
1620 KB |
Output is correct |
36 |
Correct |
43 ms |
1684 KB |
Output is correct |
37 |
Correct |
154 ms |
3032 KB |
Output is correct |
38 |
Correct |
160 ms |
3032 KB |
Output is correct |
39 |
Correct |
230 ms |
3688 KB |
Output is correct |
40 |
Correct |
301 ms |
3972 KB |
Output is correct |
41 |
Correct |
276 ms |
3968 KB |
Output is correct |
42 |
Correct |
260 ms |
3708 KB |
Output is correct |
43 |
Correct |
278 ms |
3748 KB |
Output is correct |
44 |
Correct |
280 ms |
3808 KB |
Output is correct |
45 |
Correct |
286 ms |
3832 KB |
Output is correct |
46 |
Correct |
269 ms |
3972 KB |
Output is correct |
47 |
Correct |
264 ms |
3704 KB |
Output is correct |
48 |
Correct |
311 ms |
3716 KB |
Output is correct |
49 |
Correct |
251 ms |
3700 KB |
Output is correct |
50 |
Correct |
254 ms |
3696 KB |
Output is correct |
51 |
Correct |
3 ms |
3668 KB |
Output is correct |
52 |
Correct |
345 ms |
4100 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
4 ms |
724 KB |
Output is correct |
11 |
Correct |
4 ms |
724 KB |
Output is correct |
12 |
Correct |
4 ms |
724 KB |
Output is correct |
13 |
Correct |
3 ms |
596 KB |
Output is correct |
14 |
Correct |
4 ms |
724 KB |
Output is correct |
15 |
Correct |
3 ms |
724 KB |
Output is correct |
16 |
Correct |
4 ms |
724 KB |
Output is correct |
17 |
Correct |
2 ms |
596 KB |
Output is correct |
18 |
Correct |
3 ms |
596 KB |
Output is correct |
19 |
Correct |
3 ms |
596 KB |
Output is correct |
20 |
Correct |
5 ms |
724 KB |
Output is correct |
21 |
Correct |
21 ms |
1108 KB |
Output is correct |
22 |
Correct |
22 ms |
1236 KB |
Output is correct |
23 |
Correct |
10 ms |
1032 KB |
Output is correct |
24 |
Correct |
34 ms |
1612 KB |
Output is correct |
25 |
Correct |
39 ms |
1620 KB |
Output is correct |
26 |
Correct |
40 ms |
1692 KB |
Output is correct |
27 |
Correct |
40 ms |
1696 KB |
Output is correct |
28 |
Correct |
40 ms |
1684 KB |
Output is correct |
29 |
Correct |
37 ms |
1620 KB |
Output is correct |
30 |
Correct |
37 ms |
1620 KB |
Output is correct |
31 |
Correct |
38 ms |
1696 KB |
Output is correct |
32 |
Correct |
37 ms |
1688 KB |
Output is correct |
33 |
Correct |
36 ms |
1620 KB |
Output is correct |
34 |
Correct |
44 ms |
1620 KB |
Output is correct |
35 |
Correct |
38 ms |
1620 KB |
Output is correct |
36 |
Correct |
43 ms |
1684 KB |
Output is correct |
37 |
Correct |
154 ms |
3032 KB |
Output is correct |
38 |
Correct |
160 ms |
3032 KB |
Output is correct |
39 |
Correct |
230 ms |
3688 KB |
Output is correct |
40 |
Correct |
301 ms |
3972 KB |
Output is correct |
41 |
Correct |
276 ms |
3968 KB |
Output is correct |
42 |
Correct |
260 ms |
3708 KB |
Output is correct |
43 |
Correct |
278 ms |
3748 KB |
Output is correct |
44 |
Correct |
280 ms |
3808 KB |
Output is correct |
45 |
Correct |
286 ms |
3832 KB |
Output is correct |
46 |
Correct |
269 ms |
3972 KB |
Output is correct |
47 |
Correct |
264 ms |
3704 KB |
Output is correct |
48 |
Correct |
311 ms |
3716 KB |
Output is correct |
49 |
Correct |
251 ms |
3700 KB |
Output is correct |
50 |
Correct |
254 ms |
3696 KB |
Output is correct |
51 |
Correct |
3 ms |
3668 KB |
Output is correct |
52 |
Correct |
345 ms |
4100 KB |
Output is correct |
53 |
Correct |
382 ms |
4556 KB |
Output is correct |
54 |
Correct |
517 ms |
5176 KB |
Output is correct |
55 |
Incorrect |
653 ms |
5356 KB |
Output isn't correct |
56 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
4 ms |
724 KB |
Output is correct |
11 |
Correct |
4 ms |
724 KB |
Output is correct |
12 |
Correct |
4 ms |
724 KB |
Output is correct |
13 |
Correct |
3 ms |
596 KB |
Output is correct |
14 |
Correct |
4 ms |
724 KB |
Output is correct |
15 |
Correct |
3 ms |
724 KB |
Output is correct |
16 |
Correct |
4 ms |
724 KB |
Output is correct |
17 |
Correct |
2 ms |
596 KB |
Output is correct |
18 |
Correct |
3 ms |
596 KB |
Output is correct |
19 |
Correct |
3 ms |
596 KB |
Output is correct |
20 |
Correct |
5 ms |
724 KB |
Output is correct |
21 |
Correct |
21 ms |
1108 KB |
Output is correct |
22 |
Correct |
22 ms |
1236 KB |
Output is correct |
23 |
Correct |
10 ms |
1032 KB |
Output is correct |
24 |
Correct |
34 ms |
1612 KB |
Output is correct |
25 |
Correct |
39 ms |
1620 KB |
Output is correct |
26 |
Correct |
40 ms |
1692 KB |
Output is correct |
27 |
Correct |
40 ms |
1696 KB |
Output is correct |
28 |
Correct |
40 ms |
1684 KB |
Output is correct |
29 |
Correct |
37 ms |
1620 KB |
Output is correct |
30 |
Correct |
37 ms |
1620 KB |
Output is correct |
31 |
Correct |
38 ms |
1696 KB |
Output is correct |
32 |
Correct |
37 ms |
1688 KB |
Output is correct |
33 |
Correct |
36 ms |
1620 KB |
Output is correct |
34 |
Correct |
44 ms |
1620 KB |
Output is correct |
35 |
Correct |
38 ms |
1620 KB |
Output is correct |
36 |
Correct |
43 ms |
1684 KB |
Output is correct |
37 |
Correct |
154 ms |
3032 KB |
Output is correct |
38 |
Correct |
160 ms |
3032 KB |
Output is correct |
39 |
Correct |
230 ms |
3688 KB |
Output is correct |
40 |
Correct |
301 ms |
3972 KB |
Output is correct |
41 |
Correct |
276 ms |
3968 KB |
Output is correct |
42 |
Correct |
260 ms |
3708 KB |
Output is correct |
43 |
Correct |
278 ms |
3748 KB |
Output is correct |
44 |
Correct |
280 ms |
3808 KB |
Output is correct |
45 |
Correct |
286 ms |
3832 KB |
Output is correct |
46 |
Correct |
269 ms |
3972 KB |
Output is correct |
47 |
Correct |
264 ms |
3704 KB |
Output is correct |
48 |
Correct |
311 ms |
3716 KB |
Output is correct |
49 |
Correct |
251 ms |
3700 KB |
Output is correct |
50 |
Correct |
254 ms |
3696 KB |
Output is correct |
51 |
Correct |
3 ms |
3668 KB |
Output is correct |
52 |
Correct |
345 ms |
4100 KB |
Output is correct |
53 |
Correct |
382 ms |
4556 KB |
Output is correct |
54 |
Correct |
517 ms |
5176 KB |
Output is correct |
55 |
Incorrect |
653 ms |
5356 KB |
Output isn't correct |
56 |
Halted |
0 ms |
0 KB |
- |