#include <bits/stdc++.h>
using namespace std;
const int maxN = 500;
const int maxS = 350 * 350;
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
5 ms |
816 KB |
Output is correct |
11 |
Correct |
4 ms |
724 KB |
Output is correct |
12 |
Correct |
4 ms |
812 KB |
Output is correct |
13 |
Correct |
4 ms |
724 KB |
Output is correct |
14 |
Correct |
3 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 |
724 KB |
Output is correct |
19 |
Correct |
3 ms |
756 KB |
Output is correct |
20 |
Correct |
4 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
5 ms |
816 KB |
Output is correct |
11 |
Correct |
4 ms |
724 KB |
Output is correct |
12 |
Correct |
4 ms |
812 KB |
Output is correct |
13 |
Correct |
4 ms |
724 KB |
Output is correct |
14 |
Correct |
3 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 |
724 KB |
Output is correct |
19 |
Correct |
3 ms |
756 KB |
Output is correct |
20 |
Correct |
4 ms |
724 KB |
Output is correct |
21 |
Correct |
18 ms |
1324 KB |
Output is correct |
22 |
Correct |
29 ms |
1472 KB |
Output is correct |
23 |
Correct |
11 ms |
1108 KB |
Output is correct |
24 |
Correct |
37 ms |
1772 KB |
Output is correct |
25 |
Correct |
40 ms |
1748 KB |
Output is correct |
26 |
Correct |
43 ms |
1856 KB |
Output is correct |
27 |
Correct |
42 ms |
1748 KB |
Output is correct |
28 |
Correct |
41 ms |
1844 KB |
Output is correct |
29 |
Correct |
41 ms |
1748 KB |
Output is correct |
30 |
Correct |
42 ms |
1748 KB |
Output is correct |
31 |
Correct |
42 ms |
1748 KB |
Output is correct |
32 |
Correct |
47 ms |
1848 KB |
Output is correct |
33 |
Correct |
41 ms |
1848 KB |
Output is correct |
34 |
Correct |
40 ms |
1844 KB |
Output is correct |
35 |
Correct |
47 ms |
1748 KB |
Output is correct |
36 |
Correct |
41 ms |
1856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
5 ms |
816 KB |
Output is correct |
11 |
Correct |
4 ms |
724 KB |
Output is correct |
12 |
Correct |
4 ms |
812 KB |
Output is correct |
13 |
Correct |
4 ms |
724 KB |
Output is correct |
14 |
Correct |
3 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 |
724 KB |
Output is correct |
19 |
Correct |
3 ms |
756 KB |
Output is correct |
20 |
Correct |
4 ms |
724 KB |
Output is correct |
21 |
Correct |
18 ms |
1324 KB |
Output is correct |
22 |
Correct |
29 ms |
1472 KB |
Output is correct |
23 |
Correct |
11 ms |
1108 KB |
Output is correct |
24 |
Correct |
37 ms |
1772 KB |
Output is correct |
25 |
Correct |
40 ms |
1748 KB |
Output is correct |
26 |
Correct |
43 ms |
1856 KB |
Output is correct |
27 |
Correct |
42 ms |
1748 KB |
Output is correct |
28 |
Correct |
41 ms |
1844 KB |
Output is correct |
29 |
Correct |
41 ms |
1748 KB |
Output is correct |
30 |
Correct |
42 ms |
1748 KB |
Output is correct |
31 |
Correct |
42 ms |
1748 KB |
Output is correct |
32 |
Correct |
47 ms |
1848 KB |
Output is correct |
33 |
Correct |
41 ms |
1848 KB |
Output is correct |
34 |
Correct |
40 ms |
1844 KB |
Output is correct |
35 |
Correct |
47 ms |
1748 KB |
Output is correct |
36 |
Correct |
41 ms |
1856 KB |
Output is correct |
37 |
Correct |
172 ms |
3344 KB |
Output is correct |
38 |
Correct |
169 ms |
3348 KB |
Output is correct |
39 |
Correct |
233 ms |
4068 KB |
Output is correct |
40 |
Correct |
326 ms |
4404 KB |
Output is correct |
41 |
Correct |
278 ms |
4396 KB |
Output is correct |
42 |
Correct |
270 ms |
4172 KB |
Output is correct |
43 |
Correct |
285 ms |
4172 KB |
Output is correct |
44 |
Correct |
294 ms |
4196 KB |
Output is correct |
45 |
Correct |
308 ms |
4224 KB |
Output is correct |
46 |
Correct |
293 ms |
4308 KB |
Output is correct |
47 |
Correct |
273 ms |
4104 KB |
Output is correct |
48 |
Correct |
295 ms |
4172 KB |
Output is correct |
49 |
Correct |
267 ms |
4104 KB |
Output is correct |
50 |
Correct |
279 ms |
4096 KB |
Output is correct |
51 |
Correct |
3 ms |
4052 KB |
Output is correct |
52 |
Correct |
355 ms |
4520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
5 ms |
816 KB |
Output is correct |
11 |
Correct |
4 ms |
724 KB |
Output is correct |
12 |
Correct |
4 ms |
812 KB |
Output is correct |
13 |
Correct |
4 ms |
724 KB |
Output is correct |
14 |
Correct |
3 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 |
724 KB |
Output is correct |
19 |
Correct |
3 ms |
756 KB |
Output is correct |
20 |
Correct |
4 ms |
724 KB |
Output is correct |
21 |
Correct |
18 ms |
1324 KB |
Output is correct |
22 |
Correct |
29 ms |
1472 KB |
Output is correct |
23 |
Correct |
11 ms |
1108 KB |
Output is correct |
24 |
Correct |
37 ms |
1772 KB |
Output is correct |
25 |
Correct |
40 ms |
1748 KB |
Output is correct |
26 |
Correct |
43 ms |
1856 KB |
Output is correct |
27 |
Correct |
42 ms |
1748 KB |
Output is correct |
28 |
Correct |
41 ms |
1844 KB |
Output is correct |
29 |
Correct |
41 ms |
1748 KB |
Output is correct |
30 |
Correct |
42 ms |
1748 KB |
Output is correct |
31 |
Correct |
42 ms |
1748 KB |
Output is correct |
32 |
Correct |
47 ms |
1848 KB |
Output is correct |
33 |
Correct |
41 ms |
1848 KB |
Output is correct |
34 |
Correct |
40 ms |
1844 KB |
Output is correct |
35 |
Correct |
47 ms |
1748 KB |
Output is correct |
36 |
Correct |
41 ms |
1856 KB |
Output is correct |
37 |
Correct |
172 ms |
3344 KB |
Output is correct |
38 |
Correct |
169 ms |
3348 KB |
Output is correct |
39 |
Correct |
233 ms |
4068 KB |
Output is correct |
40 |
Correct |
326 ms |
4404 KB |
Output is correct |
41 |
Correct |
278 ms |
4396 KB |
Output is correct |
42 |
Correct |
270 ms |
4172 KB |
Output is correct |
43 |
Correct |
285 ms |
4172 KB |
Output is correct |
44 |
Correct |
294 ms |
4196 KB |
Output is correct |
45 |
Correct |
308 ms |
4224 KB |
Output is correct |
46 |
Correct |
293 ms |
4308 KB |
Output is correct |
47 |
Correct |
273 ms |
4104 KB |
Output is correct |
48 |
Correct |
295 ms |
4172 KB |
Output is correct |
49 |
Correct |
267 ms |
4104 KB |
Output is correct |
50 |
Correct |
279 ms |
4096 KB |
Output is correct |
51 |
Correct |
3 ms |
4052 KB |
Output is correct |
52 |
Correct |
355 ms |
4520 KB |
Output is correct |
53 |
Correct |
412 ms |
4972 KB |
Output is correct |
54 |
Correct |
565 ms |
5724 KB |
Output is correct |
55 |
Correct |
648 ms |
5844 KB |
Output is correct |
56 |
Correct |
439 ms |
5076 KB |
Output is correct |
57 |
Correct |
668 ms |
5836 KB |
Output is correct |
58 |
Correct |
573 ms |
5732 KB |
Output is correct |
59 |
Correct |
602 ms |
5832 KB |
Output is correct |
60 |
Correct |
4 ms |
5588 KB |
Output is correct |
61 |
Correct |
629 ms |
5732 KB |
Output is correct |
62 |
Correct |
543 ms |
5324 KB |
Output is correct |
63 |
Correct |
547 ms |
5404 KB |
Output is correct |
64 |
Correct |
574 ms |
5312 KB |
Output is correct |
65 |
Correct |
380 ms |
5088 KB |
Output is correct |
66 |
Correct |
383 ms |
5004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
5 ms |
816 KB |
Output is correct |
11 |
Correct |
4 ms |
724 KB |
Output is correct |
12 |
Correct |
4 ms |
812 KB |
Output is correct |
13 |
Correct |
4 ms |
724 KB |
Output is correct |
14 |
Correct |
3 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 |
724 KB |
Output is correct |
19 |
Correct |
3 ms |
756 KB |
Output is correct |
20 |
Correct |
4 ms |
724 KB |
Output is correct |
21 |
Correct |
18 ms |
1324 KB |
Output is correct |
22 |
Correct |
29 ms |
1472 KB |
Output is correct |
23 |
Correct |
11 ms |
1108 KB |
Output is correct |
24 |
Correct |
37 ms |
1772 KB |
Output is correct |
25 |
Correct |
40 ms |
1748 KB |
Output is correct |
26 |
Correct |
43 ms |
1856 KB |
Output is correct |
27 |
Correct |
42 ms |
1748 KB |
Output is correct |
28 |
Correct |
41 ms |
1844 KB |
Output is correct |
29 |
Correct |
41 ms |
1748 KB |
Output is correct |
30 |
Correct |
42 ms |
1748 KB |
Output is correct |
31 |
Correct |
42 ms |
1748 KB |
Output is correct |
32 |
Correct |
47 ms |
1848 KB |
Output is correct |
33 |
Correct |
41 ms |
1848 KB |
Output is correct |
34 |
Correct |
40 ms |
1844 KB |
Output is correct |
35 |
Correct |
47 ms |
1748 KB |
Output is correct |
36 |
Correct |
41 ms |
1856 KB |
Output is correct |
37 |
Correct |
172 ms |
3344 KB |
Output is correct |
38 |
Correct |
169 ms |
3348 KB |
Output is correct |
39 |
Correct |
233 ms |
4068 KB |
Output is correct |
40 |
Correct |
326 ms |
4404 KB |
Output is correct |
41 |
Correct |
278 ms |
4396 KB |
Output is correct |
42 |
Correct |
270 ms |
4172 KB |
Output is correct |
43 |
Correct |
285 ms |
4172 KB |
Output is correct |
44 |
Correct |
294 ms |
4196 KB |
Output is correct |
45 |
Correct |
308 ms |
4224 KB |
Output is correct |
46 |
Correct |
293 ms |
4308 KB |
Output is correct |
47 |
Correct |
273 ms |
4104 KB |
Output is correct |
48 |
Correct |
295 ms |
4172 KB |
Output is correct |
49 |
Correct |
267 ms |
4104 KB |
Output is correct |
50 |
Correct |
279 ms |
4096 KB |
Output is correct |
51 |
Correct |
3 ms |
4052 KB |
Output is correct |
52 |
Correct |
355 ms |
4520 KB |
Output is correct |
53 |
Correct |
412 ms |
4972 KB |
Output is correct |
54 |
Correct |
565 ms |
5724 KB |
Output is correct |
55 |
Correct |
648 ms |
5844 KB |
Output is correct |
56 |
Correct |
439 ms |
5076 KB |
Output is correct |
57 |
Correct |
668 ms |
5836 KB |
Output is correct |
58 |
Correct |
573 ms |
5732 KB |
Output is correct |
59 |
Correct |
602 ms |
5832 KB |
Output is correct |
60 |
Correct |
4 ms |
5588 KB |
Output is correct |
61 |
Correct |
629 ms |
5732 KB |
Output is correct |
62 |
Correct |
543 ms |
5324 KB |
Output is correct |
63 |
Correct |
547 ms |
5404 KB |
Output is correct |
64 |
Correct |
574 ms |
5312 KB |
Output is correct |
65 |
Correct |
380 ms |
5088 KB |
Output is correct |
66 |
Correct |
383 ms |
5004 KB |
Output is correct |
67 |
Correct |
868 ms |
6472 KB |
Output is correct |
68 |
Correct |
5 ms |
7764 KB |
Output is correct |
69 |
Execution timed out |
1080 ms |
7764 KB |
Time limit exceeded |
70 |
Halted |
0 ms |
0 KB |
- |