#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
const int N = 510;
const int A = 510;
bitset<250069> bt[N], sv;
int n, a[N];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tt = 1;
//cin >> tt;
while (tt--) {
cin >> n;
sv[0] = 1;
for (int i = 1;i <= n;i++)
cin >> a[i], sv |= (sv << a[i]);
int s = accumulate(a + 1, a + n + 1, 0);
if (s % 2 == 1 || sv[s / 2] == 0) {
cout << '0';
return 0;
}
s /= 2;
for (int j = 1;j <= n;j++) {
bitset<250069> t;
t[0] = 1;
for (int i = 1;i <= n;i++) {
if (i == j)
continue;
t |= (t << a[i]);
}
bt[j] = t;
}
vector<int> ans;
for (int i = (a[1] % 2 == 1 ? 1 : 2);i < N * A;i += 2) {
int ok = 1;
for (int j = 1;j <= n;j++) {
int r = i - a[j];
if (r & 1) {
ok = 0;
break;
}
r /= 2;
int x = s + r;
if (bt[j][x] == 0) {
ok = 0;
break;
}
}
if (ok)
ans.push_back(i);
}
cout << ans.size() << '\n';
for (auto i : ans)
cout << i << ' ';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
2648 KB |
Output is correct |
5 |
Correct |
2 ms |
2652 KB |
Output is correct |
6 |
Correct |
2 ms |
2652 KB |
Output is correct |
7 |
Correct |
2 ms |
2648 KB |
Output is correct |
8 |
Correct |
2 ms |
2652 KB |
Output is correct |
9 |
Correct |
2 ms |
2652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
2648 KB |
Output is correct |
5 |
Correct |
2 ms |
2652 KB |
Output is correct |
6 |
Correct |
2 ms |
2652 KB |
Output is correct |
7 |
Correct |
2 ms |
2648 KB |
Output is correct |
8 |
Correct |
2 ms |
2652 KB |
Output is correct |
9 |
Correct |
2 ms |
2652 KB |
Output is correct |
10 |
Correct |
6 ms |
2652 KB |
Output is correct |
11 |
Correct |
6 ms |
2652 KB |
Output is correct |
12 |
Correct |
6 ms |
2652 KB |
Output is correct |
13 |
Correct |
5 ms |
2652 KB |
Output is correct |
14 |
Correct |
5 ms |
2652 KB |
Output is correct |
15 |
Correct |
5 ms |
2652 KB |
Output is correct |
16 |
Correct |
6 ms |
2652 KB |
Output is correct |
17 |
Correct |
3 ms |
2652 KB |
Output is correct |
18 |
Correct |
4 ms |
2752 KB |
Output is correct |
19 |
Correct |
5 ms |
2748 KB |
Output is correct |
20 |
Correct |
6 ms |
2652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
2648 KB |
Output is correct |
5 |
Correct |
2 ms |
2652 KB |
Output is correct |
6 |
Correct |
2 ms |
2652 KB |
Output is correct |
7 |
Correct |
2 ms |
2648 KB |
Output is correct |
8 |
Correct |
2 ms |
2652 KB |
Output is correct |
9 |
Correct |
2 ms |
2652 KB |
Output is correct |
10 |
Correct |
6 ms |
2652 KB |
Output is correct |
11 |
Correct |
6 ms |
2652 KB |
Output is correct |
12 |
Correct |
6 ms |
2652 KB |
Output is correct |
13 |
Correct |
5 ms |
2652 KB |
Output is correct |
14 |
Correct |
5 ms |
2652 KB |
Output is correct |
15 |
Correct |
5 ms |
2652 KB |
Output is correct |
16 |
Correct |
6 ms |
2652 KB |
Output is correct |
17 |
Correct |
3 ms |
2652 KB |
Output is correct |
18 |
Correct |
4 ms |
2752 KB |
Output is correct |
19 |
Correct |
5 ms |
2748 KB |
Output is correct |
20 |
Correct |
6 ms |
2652 KB |
Output is correct |
21 |
Correct |
25 ms |
2748 KB |
Output is correct |
22 |
Correct |
32 ms |
4800 KB |
Output is correct |
23 |
Correct |
15 ms |
2652 KB |
Output is correct |
24 |
Correct |
55 ms |
4692 KB |
Output is correct |
25 |
Correct |
50 ms |
4688 KB |
Output is correct |
26 |
Correct |
56 ms |
4780 KB |
Output is correct |
27 |
Correct |
56 ms |
4692 KB |
Output is correct |
28 |
Correct |
68 ms |
4692 KB |
Output is correct |
29 |
Correct |
57 ms |
4800 KB |
Output is correct |
30 |
Correct |
56 ms |
4688 KB |
Output is correct |
31 |
Correct |
57 ms |
4692 KB |
Output is correct |
32 |
Correct |
62 ms |
4776 KB |
Output is correct |
33 |
Correct |
61 ms |
4780 KB |
Output is correct |
34 |
Correct |
68 ms |
4776 KB |
Output is correct |
35 |
Correct |
56 ms |
4688 KB |
Output is correct |
36 |
Correct |
57 ms |
4692 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
2648 KB |
Output is correct |
5 |
Correct |
2 ms |
2652 KB |
Output is correct |
6 |
Correct |
2 ms |
2652 KB |
Output is correct |
7 |
Correct |
2 ms |
2648 KB |
Output is correct |
8 |
Correct |
2 ms |
2652 KB |
Output is correct |
9 |
Correct |
2 ms |
2652 KB |
Output is correct |
10 |
Correct |
6 ms |
2652 KB |
Output is correct |
11 |
Correct |
6 ms |
2652 KB |
Output is correct |
12 |
Correct |
6 ms |
2652 KB |
Output is correct |
13 |
Correct |
5 ms |
2652 KB |
Output is correct |
14 |
Correct |
5 ms |
2652 KB |
Output is correct |
15 |
Correct |
5 ms |
2652 KB |
Output is correct |
16 |
Correct |
6 ms |
2652 KB |
Output is correct |
17 |
Correct |
3 ms |
2652 KB |
Output is correct |
18 |
Correct |
4 ms |
2752 KB |
Output is correct |
19 |
Correct |
5 ms |
2748 KB |
Output is correct |
20 |
Correct |
6 ms |
2652 KB |
Output is correct |
21 |
Correct |
25 ms |
2748 KB |
Output is correct |
22 |
Correct |
32 ms |
4800 KB |
Output is correct |
23 |
Correct |
15 ms |
2652 KB |
Output is correct |
24 |
Correct |
55 ms |
4692 KB |
Output is correct |
25 |
Correct |
50 ms |
4688 KB |
Output is correct |
26 |
Correct |
56 ms |
4780 KB |
Output is correct |
27 |
Correct |
56 ms |
4692 KB |
Output is correct |
28 |
Correct |
68 ms |
4692 KB |
Output is correct |
29 |
Correct |
57 ms |
4800 KB |
Output is correct |
30 |
Correct |
56 ms |
4688 KB |
Output is correct |
31 |
Correct |
57 ms |
4692 KB |
Output is correct |
32 |
Correct |
62 ms |
4776 KB |
Output is correct |
33 |
Correct |
61 ms |
4780 KB |
Output is correct |
34 |
Correct |
68 ms |
4776 KB |
Output is correct |
35 |
Correct |
56 ms |
4688 KB |
Output is correct |
36 |
Correct |
57 ms |
4692 KB |
Output is correct |
37 |
Correct |
224 ms |
7076 KB |
Output is correct |
38 |
Correct |
241 ms |
6992 KB |
Output is correct |
39 |
Correct |
355 ms |
8888 KB |
Output is correct |
40 |
Correct |
408 ms |
8884 KB |
Output is correct |
41 |
Correct |
396 ms |
8788 KB |
Output is correct |
42 |
Correct |
350 ms |
9044 KB |
Output is correct |
43 |
Correct |
335 ms |
9140 KB |
Output is correct |
44 |
Correct |
349 ms |
9132 KB |
Output is correct |
45 |
Correct |
353 ms |
9136 KB |
Output is correct |
46 |
Correct |
404 ms |
8880 KB |
Output is correct |
47 |
Correct |
360 ms |
9044 KB |
Output is correct |
48 |
Correct |
361 ms |
9044 KB |
Output is correct |
49 |
Correct |
343 ms |
8880 KB |
Output is correct |
50 |
Correct |
348 ms |
8876 KB |
Output is correct |
51 |
Correct |
2 ms |
348 KB |
Output is correct |
52 |
Correct |
413 ms |
9188 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
2648 KB |
Output is correct |
5 |
Correct |
2 ms |
2652 KB |
Output is correct |
6 |
Correct |
2 ms |
2652 KB |
Output is correct |
7 |
Correct |
2 ms |
2648 KB |
Output is correct |
8 |
Correct |
2 ms |
2652 KB |
Output is correct |
9 |
Correct |
2 ms |
2652 KB |
Output is correct |
10 |
Correct |
6 ms |
2652 KB |
Output is correct |
11 |
Correct |
6 ms |
2652 KB |
Output is correct |
12 |
Correct |
6 ms |
2652 KB |
Output is correct |
13 |
Correct |
5 ms |
2652 KB |
Output is correct |
14 |
Correct |
5 ms |
2652 KB |
Output is correct |
15 |
Correct |
5 ms |
2652 KB |
Output is correct |
16 |
Correct |
6 ms |
2652 KB |
Output is correct |
17 |
Correct |
3 ms |
2652 KB |
Output is correct |
18 |
Correct |
4 ms |
2752 KB |
Output is correct |
19 |
Correct |
5 ms |
2748 KB |
Output is correct |
20 |
Correct |
6 ms |
2652 KB |
Output is correct |
21 |
Correct |
25 ms |
2748 KB |
Output is correct |
22 |
Correct |
32 ms |
4800 KB |
Output is correct |
23 |
Correct |
15 ms |
2652 KB |
Output is correct |
24 |
Correct |
55 ms |
4692 KB |
Output is correct |
25 |
Correct |
50 ms |
4688 KB |
Output is correct |
26 |
Correct |
56 ms |
4780 KB |
Output is correct |
27 |
Correct |
56 ms |
4692 KB |
Output is correct |
28 |
Correct |
68 ms |
4692 KB |
Output is correct |
29 |
Correct |
57 ms |
4800 KB |
Output is correct |
30 |
Correct |
56 ms |
4688 KB |
Output is correct |
31 |
Correct |
57 ms |
4692 KB |
Output is correct |
32 |
Correct |
62 ms |
4776 KB |
Output is correct |
33 |
Correct |
61 ms |
4780 KB |
Output is correct |
34 |
Correct |
68 ms |
4776 KB |
Output is correct |
35 |
Correct |
56 ms |
4688 KB |
Output is correct |
36 |
Correct |
57 ms |
4692 KB |
Output is correct |
37 |
Correct |
224 ms |
7076 KB |
Output is correct |
38 |
Correct |
241 ms |
6992 KB |
Output is correct |
39 |
Correct |
355 ms |
8888 KB |
Output is correct |
40 |
Correct |
408 ms |
8884 KB |
Output is correct |
41 |
Correct |
396 ms |
8788 KB |
Output is correct |
42 |
Correct |
350 ms |
9044 KB |
Output is correct |
43 |
Correct |
335 ms |
9140 KB |
Output is correct |
44 |
Correct |
349 ms |
9132 KB |
Output is correct |
45 |
Correct |
353 ms |
9136 KB |
Output is correct |
46 |
Correct |
404 ms |
8880 KB |
Output is correct |
47 |
Correct |
360 ms |
9044 KB |
Output is correct |
48 |
Correct |
361 ms |
9044 KB |
Output is correct |
49 |
Correct |
343 ms |
8880 KB |
Output is correct |
50 |
Correct |
348 ms |
8876 KB |
Output is correct |
51 |
Correct |
2 ms |
348 KB |
Output is correct |
52 |
Correct |
413 ms |
9188 KB |
Output is correct |
53 |
Correct |
501 ms |
11088 KB |
Output is correct |
54 |
Correct |
693 ms |
13224 KB |
Output is correct |
55 |
Correct |
704 ms |
13784 KB |
Output is correct |
56 |
Correct |
522 ms |
11192 KB |
Output is correct |
57 |
Correct |
745 ms |
13636 KB |
Output is correct |
58 |
Correct |
684 ms |
13228 KB |
Output is correct |
59 |
Correct |
698 ms |
13360 KB |
Output is correct |
60 |
Correct |
4 ms |
344 KB |
Output is correct |
61 |
Correct |
696 ms |
13664 KB |
Output is correct |
62 |
Correct |
587 ms |
11480 KB |
Output is correct |
63 |
Correct |
592 ms |
11564 KB |
Output is correct |
64 |
Correct |
563 ms |
11476 KB |
Output is correct |
65 |
Correct |
552 ms |
10932 KB |
Output is correct |
66 |
Correct |
556 ms |
11092 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
2648 KB |
Output is correct |
5 |
Correct |
2 ms |
2652 KB |
Output is correct |
6 |
Correct |
2 ms |
2652 KB |
Output is correct |
7 |
Correct |
2 ms |
2648 KB |
Output is correct |
8 |
Correct |
2 ms |
2652 KB |
Output is correct |
9 |
Correct |
2 ms |
2652 KB |
Output is correct |
10 |
Correct |
6 ms |
2652 KB |
Output is correct |
11 |
Correct |
6 ms |
2652 KB |
Output is correct |
12 |
Correct |
6 ms |
2652 KB |
Output is correct |
13 |
Correct |
5 ms |
2652 KB |
Output is correct |
14 |
Correct |
5 ms |
2652 KB |
Output is correct |
15 |
Correct |
5 ms |
2652 KB |
Output is correct |
16 |
Correct |
6 ms |
2652 KB |
Output is correct |
17 |
Correct |
3 ms |
2652 KB |
Output is correct |
18 |
Correct |
4 ms |
2752 KB |
Output is correct |
19 |
Correct |
5 ms |
2748 KB |
Output is correct |
20 |
Correct |
6 ms |
2652 KB |
Output is correct |
21 |
Correct |
25 ms |
2748 KB |
Output is correct |
22 |
Correct |
32 ms |
4800 KB |
Output is correct |
23 |
Correct |
15 ms |
2652 KB |
Output is correct |
24 |
Correct |
55 ms |
4692 KB |
Output is correct |
25 |
Correct |
50 ms |
4688 KB |
Output is correct |
26 |
Correct |
56 ms |
4780 KB |
Output is correct |
27 |
Correct |
56 ms |
4692 KB |
Output is correct |
28 |
Correct |
68 ms |
4692 KB |
Output is correct |
29 |
Correct |
57 ms |
4800 KB |
Output is correct |
30 |
Correct |
56 ms |
4688 KB |
Output is correct |
31 |
Correct |
57 ms |
4692 KB |
Output is correct |
32 |
Correct |
62 ms |
4776 KB |
Output is correct |
33 |
Correct |
61 ms |
4780 KB |
Output is correct |
34 |
Correct |
68 ms |
4776 KB |
Output is correct |
35 |
Correct |
56 ms |
4688 KB |
Output is correct |
36 |
Correct |
57 ms |
4692 KB |
Output is correct |
37 |
Correct |
224 ms |
7076 KB |
Output is correct |
38 |
Correct |
241 ms |
6992 KB |
Output is correct |
39 |
Correct |
355 ms |
8888 KB |
Output is correct |
40 |
Correct |
408 ms |
8884 KB |
Output is correct |
41 |
Correct |
396 ms |
8788 KB |
Output is correct |
42 |
Correct |
350 ms |
9044 KB |
Output is correct |
43 |
Correct |
335 ms |
9140 KB |
Output is correct |
44 |
Correct |
349 ms |
9132 KB |
Output is correct |
45 |
Correct |
353 ms |
9136 KB |
Output is correct |
46 |
Correct |
404 ms |
8880 KB |
Output is correct |
47 |
Correct |
360 ms |
9044 KB |
Output is correct |
48 |
Correct |
361 ms |
9044 KB |
Output is correct |
49 |
Correct |
343 ms |
8880 KB |
Output is correct |
50 |
Correct |
348 ms |
8876 KB |
Output is correct |
51 |
Correct |
2 ms |
348 KB |
Output is correct |
52 |
Correct |
413 ms |
9188 KB |
Output is correct |
53 |
Correct |
501 ms |
11088 KB |
Output is correct |
54 |
Correct |
693 ms |
13224 KB |
Output is correct |
55 |
Correct |
704 ms |
13784 KB |
Output is correct |
56 |
Correct |
522 ms |
11192 KB |
Output is correct |
57 |
Correct |
745 ms |
13636 KB |
Output is correct |
58 |
Correct |
684 ms |
13228 KB |
Output is correct |
59 |
Correct |
698 ms |
13360 KB |
Output is correct |
60 |
Correct |
4 ms |
344 KB |
Output is correct |
61 |
Correct |
696 ms |
13664 KB |
Output is correct |
62 |
Correct |
587 ms |
11480 KB |
Output is correct |
63 |
Correct |
592 ms |
11564 KB |
Output is correct |
64 |
Correct |
563 ms |
11476 KB |
Output is correct |
65 |
Correct |
552 ms |
10932 KB |
Output is correct |
66 |
Correct |
556 ms |
11092 KB |
Output is correct |
67 |
Correct |
897 ms |
13380 KB |
Output is correct |
68 |
Correct |
3 ms |
348 KB |
Output is correct |
69 |
Execution timed out |
1048 ms |
12976 KB |
Time limit exceeded |
70 |
Halted |
0 ms |
0 KB |
- |