#include <bits/stdc++.h>
using namespace std;
const int maxN = 500;
const int maxS = maxN * maxN;
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 |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
724 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
596 KB |
Output is correct |
8 |
Correct |
2 ms |
792 KB |
Output is correct |
9 |
Correct |
1 ms |
724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
724 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
596 KB |
Output is correct |
8 |
Correct |
2 ms |
792 KB |
Output is correct |
9 |
Correct |
1 ms |
724 KB |
Output is correct |
10 |
Correct |
10 ms |
1344 KB |
Output is correct |
11 |
Correct |
10 ms |
1236 KB |
Output is correct |
12 |
Correct |
9 ms |
1348 KB |
Output is correct |
13 |
Correct |
8 ms |
1176 KB |
Output is correct |
14 |
Correct |
8 ms |
1364 KB |
Output is correct |
15 |
Correct |
8 ms |
1236 KB |
Output is correct |
16 |
Correct |
8 ms |
1348 KB |
Output is correct |
17 |
Correct |
3 ms |
980 KB |
Output is correct |
18 |
Correct |
5 ms |
1108 KB |
Output is correct |
19 |
Correct |
8 ms |
1228 KB |
Output is correct |
20 |
Correct |
8 ms |
1300 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
724 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
596 KB |
Output is correct |
8 |
Correct |
2 ms |
792 KB |
Output is correct |
9 |
Correct |
1 ms |
724 KB |
Output is correct |
10 |
Correct |
10 ms |
1344 KB |
Output is correct |
11 |
Correct |
10 ms |
1236 KB |
Output is correct |
12 |
Correct |
9 ms |
1348 KB |
Output is correct |
13 |
Correct |
8 ms |
1176 KB |
Output is correct |
14 |
Correct |
8 ms |
1364 KB |
Output is correct |
15 |
Correct |
8 ms |
1236 KB |
Output is correct |
16 |
Correct |
8 ms |
1348 KB |
Output is correct |
17 |
Correct |
3 ms |
980 KB |
Output is correct |
18 |
Correct |
5 ms |
1108 KB |
Output is correct |
19 |
Correct |
8 ms |
1228 KB |
Output is correct |
20 |
Correct |
8 ms |
1300 KB |
Output is correct |
21 |
Correct |
35 ms |
2260 KB |
Output is correct |
22 |
Correct |
48 ms |
2644 KB |
Output is correct |
23 |
Correct |
23 ms |
1956 KB |
Output is correct |
24 |
Correct |
74 ms |
3288 KB |
Output is correct |
25 |
Correct |
85 ms |
3300 KB |
Output is correct |
26 |
Correct |
83 ms |
3472 KB |
Output is correct |
27 |
Correct |
82 ms |
3484 KB |
Output is correct |
28 |
Correct |
82 ms |
3412 KB |
Output is correct |
29 |
Correct |
85 ms |
3468 KB |
Output is correct |
30 |
Correct |
82 ms |
3464 KB |
Output is correct |
31 |
Correct |
82 ms |
3480 KB |
Output is correct |
32 |
Correct |
86 ms |
3472 KB |
Output is correct |
33 |
Correct |
80 ms |
3540 KB |
Output is correct |
34 |
Correct |
82 ms |
3464 KB |
Output is correct |
35 |
Correct |
80 ms |
3464 KB |
Output is correct |
36 |
Correct |
87 ms |
3480 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
724 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
596 KB |
Output is correct |
8 |
Correct |
2 ms |
792 KB |
Output is correct |
9 |
Correct |
1 ms |
724 KB |
Output is correct |
10 |
Correct |
10 ms |
1344 KB |
Output is correct |
11 |
Correct |
10 ms |
1236 KB |
Output is correct |
12 |
Correct |
9 ms |
1348 KB |
Output is correct |
13 |
Correct |
8 ms |
1176 KB |
Output is correct |
14 |
Correct |
8 ms |
1364 KB |
Output is correct |
15 |
Correct |
8 ms |
1236 KB |
Output is correct |
16 |
Correct |
8 ms |
1348 KB |
Output is correct |
17 |
Correct |
3 ms |
980 KB |
Output is correct |
18 |
Correct |
5 ms |
1108 KB |
Output is correct |
19 |
Correct |
8 ms |
1228 KB |
Output is correct |
20 |
Correct |
8 ms |
1300 KB |
Output is correct |
21 |
Correct |
35 ms |
2260 KB |
Output is correct |
22 |
Correct |
48 ms |
2644 KB |
Output is correct |
23 |
Correct |
23 ms |
1956 KB |
Output is correct |
24 |
Correct |
74 ms |
3288 KB |
Output is correct |
25 |
Correct |
85 ms |
3300 KB |
Output is correct |
26 |
Correct |
83 ms |
3472 KB |
Output is correct |
27 |
Correct |
82 ms |
3484 KB |
Output is correct |
28 |
Correct |
82 ms |
3412 KB |
Output is correct |
29 |
Correct |
85 ms |
3468 KB |
Output is correct |
30 |
Correct |
82 ms |
3464 KB |
Output is correct |
31 |
Correct |
82 ms |
3480 KB |
Output is correct |
32 |
Correct |
86 ms |
3472 KB |
Output is correct |
33 |
Correct |
80 ms |
3540 KB |
Output is correct |
34 |
Correct |
82 ms |
3464 KB |
Output is correct |
35 |
Correct |
80 ms |
3464 KB |
Output is correct |
36 |
Correct |
87 ms |
3480 KB |
Output is correct |
37 |
Correct |
365 ms |
6540 KB |
Output is correct |
38 |
Correct |
346 ms |
6484 KB |
Output is correct |
39 |
Correct |
591 ms |
7992 KB |
Output is correct |
40 |
Correct |
748 ms |
8668 KB |
Output is correct |
41 |
Correct |
767 ms |
8668 KB |
Output is correct |
42 |
Correct |
667 ms |
8052 KB |
Output is correct |
43 |
Correct |
677 ms |
8000 KB |
Output is correct |
44 |
Correct |
670 ms |
8120 KB |
Output is correct |
45 |
Correct |
660 ms |
8184 KB |
Output is correct |
46 |
Correct |
695 ms |
8780 KB |
Output is correct |
47 |
Correct |
596 ms |
8048 KB |
Output is correct |
48 |
Correct |
611 ms |
8056 KB |
Output is correct |
49 |
Correct |
612 ms |
8140 KB |
Output is correct |
50 |
Correct |
628 ms |
8052 KB |
Output is correct |
51 |
Correct |
6 ms |
8020 KB |
Output is correct |
52 |
Correct |
754 ms |
8796 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
724 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
596 KB |
Output is correct |
8 |
Correct |
2 ms |
792 KB |
Output is correct |
9 |
Correct |
1 ms |
724 KB |
Output is correct |
10 |
Correct |
10 ms |
1344 KB |
Output is correct |
11 |
Correct |
10 ms |
1236 KB |
Output is correct |
12 |
Correct |
9 ms |
1348 KB |
Output is correct |
13 |
Correct |
8 ms |
1176 KB |
Output is correct |
14 |
Correct |
8 ms |
1364 KB |
Output is correct |
15 |
Correct |
8 ms |
1236 KB |
Output is correct |
16 |
Correct |
8 ms |
1348 KB |
Output is correct |
17 |
Correct |
3 ms |
980 KB |
Output is correct |
18 |
Correct |
5 ms |
1108 KB |
Output is correct |
19 |
Correct |
8 ms |
1228 KB |
Output is correct |
20 |
Correct |
8 ms |
1300 KB |
Output is correct |
21 |
Correct |
35 ms |
2260 KB |
Output is correct |
22 |
Correct |
48 ms |
2644 KB |
Output is correct |
23 |
Correct |
23 ms |
1956 KB |
Output is correct |
24 |
Correct |
74 ms |
3288 KB |
Output is correct |
25 |
Correct |
85 ms |
3300 KB |
Output is correct |
26 |
Correct |
83 ms |
3472 KB |
Output is correct |
27 |
Correct |
82 ms |
3484 KB |
Output is correct |
28 |
Correct |
82 ms |
3412 KB |
Output is correct |
29 |
Correct |
85 ms |
3468 KB |
Output is correct |
30 |
Correct |
82 ms |
3464 KB |
Output is correct |
31 |
Correct |
82 ms |
3480 KB |
Output is correct |
32 |
Correct |
86 ms |
3472 KB |
Output is correct |
33 |
Correct |
80 ms |
3540 KB |
Output is correct |
34 |
Correct |
82 ms |
3464 KB |
Output is correct |
35 |
Correct |
80 ms |
3464 KB |
Output is correct |
36 |
Correct |
87 ms |
3480 KB |
Output is correct |
37 |
Correct |
365 ms |
6540 KB |
Output is correct |
38 |
Correct |
346 ms |
6484 KB |
Output is correct |
39 |
Correct |
591 ms |
7992 KB |
Output is correct |
40 |
Correct |
748 ms |
8668 KB |
Output is correct |
41 |
Correct |
767 ms |
8668 KB |
Output is correct |
42 |
Correct |
667 ms |
8052 KB |
Output is correct |
43 |
Correct |
677 ms |
8000 KB |
Output is correct |
44 |
Correct |
670 ms |
8120 KB |
Output is correct |
45 |
Correct |
660 ms |
8184 KB |
Output is correct |
46 |
Correct |
695 ms |
8780 KB |
Output is correct |
47 |
Correct |
596 ms |
8048 KB |
Output is correct |
48 |
Correct |
611 ms |
8056 KB |
Output is correct |
49 |
Correct |
612 ms |
8140 KB |
Output is correct |
50 |
Correct |
628 ms |
8052 KB |
Output is correct |
51 |
Correct |
6 ms |
8020 KB |
Output is correct |
52 |
Correct |
754 ms |
8796 KB |
Output is correct |
53 |
Correct |
914 ms |
9712 KB |
Output is correct |
54 |
Execution timed out |
1099 ms |
11092 KB |
Time limit exceeded |
55 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
724 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
596 KB |
Output is correct |
8 |
Correct |
2 ms |
792 KB |
Output is correct |
9 |
Correct |
1 ms |
724 KB |
Output is correct |
10 |
Correct |
10 ms |
1344 KB |
Output is correct |
11 |
Correct |
10 ms |
1236 KB |
Output is correct |
12 |
Correct |
9 ms |
1348 KB |
Output is correct |
13 |
Correct |
8 ms |
1176 KB |
Output is correct |
14 |
Correct |
8 ms |
1364 KB |
Output is correct |
15 |
Correct |
8 ms |
1236 KB |
Output is correct |
16 |
Correct |
8 ms |
1348 KB |
Output is correct |
17 |
Correct |
3 ms |
980 KB |
Output is correct |
18 |
Correct |
5 ms |
1108 KB |
Output is correct |
19 |
Correct |
8 ms |
1228 KB |
Output is correct |
20 |
Correct |
8 ms |
1300 KB |
Output is correct |
21 |
Correct |
35 ms |
2260 KB |
Output is correct |
22 |
Correct |
48 ms |
2644 KB |
Output is correct |
23 |
Correct |
23 ms |
1956 KB |
Output is correct |
24 |
Correct |
74 ms |
3288 KB |
Output is correct |
25 |
Correct |
85 ms |
3300 KB |
Output is correct |
26 |
Correct |
83 ms |
3472 KB |
Output is correct |
27 |
Correct |
82 ms |
3484 KB |
Output is correct |
28 |
Correct |
82 ms |
3412 KB |
Output is correct |
29 |
Correct |
85 ms |
3468 KB |
Output is correct |
30 |
Correct |
82 ms |
3464 KB |
Output is correct |
31 |
Correct |
82 ms |
3480 KB |
Output is correct |
32 |
Correct |
86 ms |
3472 KB |
Output is correct |
33 |
Correct |
80 ms |
3540 KB |
Output is correct |
34 |
Correct |
82 ms |
3464 KB |
Output is correct |
35 |
Correct |
80 ms |
3464 KB |
Output is correct |
36 |
Correct |
87 ms |
3480 KB |
Output is correct |
37 |
Correct |
365 ms |
6540 KB |
Output is correct |
38 |
Correct |
346 ms |
6484 KB |
Output is correct |
39 |
Correct |
591 ms |
7992 KB |
Output is correct |
40 |
Correct |
748 ms |
8668 KB |
Output is correct |
41 |
Correct |
767 ms |
8668 KB |
Output is correct |
42 |
Correct |
667 ms |
8052 KB |
Output is correct |
43 |
Correct |
677 ms |
8000 KB |
Output is correct |
44 |
Correct |
670 ms |
8120 KB |
Output is correct |
45 |
Correct |
660 ms |
8184 KB |
Output is correct |
46 |
Correct |
695 ms |
8780 KB |
Output is correct |
47 |
Correct |
596 ms |
8048 KB |
Output is correct |
48 |
Correct |
611 ms |
8056 KB |
Output is correct |
49 |
Correct |
612 ms |
8140 KB |
Output is correct |
50 |
Correct |
628 ms |
8052 KB |
Output is correct |
51 |
Correct |
6 ms |
8020 KB |
Output is correct |
52 |
Correct |
754 ms |
8796 KB |
Output is correct |
53 |
Correct |
914 ms |
9712 KB |
Output is correct |
54 |
Execution timed out |
1099 ms |
11092 KB |
Time limit exceeded |
55 |
Halted |
0 ms |
0 KB |
- |