#include <bits/stdc++.h>
using namespace std;
int const maxn = 500*500 + 9;
bitset <maxn> b;
int a[505];
int cnt[maxn];
int main() {
int n;
cin >> n;
b[0] = 1;
long long sum = 0;
for(int i = 0; i < n; i ++) {
cin >> a[i];
sum += a[i];
b |= b << a[i];
}
if(sum & 1 || !b[sum / 2]) {
return cout << 0, 0;
}
for(int i = 0; i < n; i ++) {
b.reset();
b[0] = 1;
for(int j = 0; j < n; j ++)
if(i != j)
b |= b << a[j];
for(int j = 1; j <= sum; j ++) {
int me = j + j - sum + a[i];
if(b[j] && me > 0)
cnt[me] ++;
}
}
vector <int> v;
for(int i = 1; i < maxn; i ++)
if(cnt[i] == n)
v.push_back(i);
cout << v.size() << '\n';
for(int i : v)
cout << i << ' ';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
3 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
3 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
7 ms |
332 KB |
Output is correct |
11 |
Correct |
7 ms |
332 KB |
Output is correct |
12 |
Correct |
7 ms |
332 KB |
Output is correct |
13 |
Correct |
6 ms |
388 KB |
Output is correct |
14 |
Correct |
7 ms |
332 KB |
Output is correct |
15 |
Correct |
6 ms |
332 KB |
Output is correct |
16 |
Correct |
7 ms |
332 KB |
Output is correct |
17 |
Correct |
4 ms |
332 KB |
Output is correct |
18 |
Correct |
5 ms |
332 KB |
Output is correct |
19 |
Correct |
8 ms |
384 KB |
Output is correct |
20 |
Correct |
7 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
3 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
7 ms |
332 KB |
Output is correct |
11 |
Correct |
7 ms |
332 KB |
Output is correct |
12 |
Correct |
7 ms |
332 KB |
Output is correct |
13 |
Correct |
6 ms |
388 KB |
Output is correct |
14 |
Correct |
7 ms |
332 KB |
Output is correct |
15 |
Correct |
6 ms |
332 KB |
Output is correct |
16 |
Correct |
7 ms |
332 KB |
Output is correct |
17 |
Correct |
4 ms |
332 KB |
Output is correct |
18 |
Correct |
5 ms |
332 KB |
Output is correct |
19 |
Correct |
8 ms |
384 KB |
Output is correct |
20 |
Correct |
7 ms |
332 KB |
Output is correct |
21 |
Correct |
31 ms |
332 KB |
Output is correct |
22 |
Correct |
38 ms |
376 KB |
Output is correct |
23 |
Correct |
18 ms |
392 KB |
Output is correct |
24 |
Correct |
61 ms |
392 KB |
Output is correct |
25 |
Correct |
61 ms |
408 KB |
Output is correct |
26 |
Correct |
69 ms |
404 KB |
Output is correct |
27 |
Correct |
69 ms |
408 KB |
Output is correct |
28 |
Correct |
73 ms |
404 KB |
Output is correct |
29 |
Correct |
69 ms |
332 KB |
Output is correct |
30 |
Correct |
67 ms |
384 KB |
Output is correct |
31 |
Correct |
69 ms |
392 KB |
Output is correct |
32 |
Correct |
70 ms |
376 KB |
Output is correct |
33 |
Correct |
68 ms |
332 KB |
Output is correct |
34 |
Correct |
72 ms |
412 KB |
Output is correct |
35 |
Correct |
69 ms |
396 KB |
Output is correct |
36 |
Correct |
68 ms |
380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
3 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
7 ms |
332 KB |
Output is correct |
11 |
Correct |
7 ms |
332 KB |
Output is correct |
12 |
Correct |
7 ms |
332 KB |
Output is correct |
13 |
Correct |
6 ms |
388 KB |
Output is correct |
14 |
Correct |
7 ms |
332 KB |
Output is correct |
15 |
Correct |
6 ms |
332 KB |
Output is correct |
16 |
Correct |
7 ms |
332 KB |
Output is correct |
17 |
Correct |
4 ms |
332 KB |
Output is correct |
18 |
Correct |
5 ms |
332 KB |
Output is correct |
19 |
Correct |
8 ms |
384 KB |
Output is correct |
20 |
Correct |
7 ms |
332 KB |
Output is correct |
21 |
Correct |
31 ms |
332 KB |
Output is correct |
22 |
Correct |
38 ms |
376 KB |
Output is correct |
23 |
Correct |
18 ms |
392 KB |
Output is correct |
24 |
Correct |
61 ms |
392 KB |
Output is correct |
25 |
Correct |
61 ms |
408 KB |
Output is correct |
26 |
Correct |
69 ms |
404 KB |
Output is correct |
27 |
Correct |
69 ms |
408 KB |
Output is correct |
28 |
Correct |
73 ms |
404 KB |
Output is correct |
29 |
Correct |
69 ms |
332 KB |
Output is correct |
30 |
Correct |
67 ms |
384 KB |
Output is correct |
31 |
Correct |
69 ms |
392 KB |
Output is correct |
32 |
Correct |
70 ms |
376 KB |
Output is correct |
33 |
Correct |
68 ms |
332 KB |
Output is correct |
34 |
Correct |
72 ms |
412 KB |
Output is correct |
35 |
Correct |
69 ms |
396 KB |
Output is correct |
36 |
Correct |
68 ms |
380 KB |
Output is correct |
37 |
Correct |
268 ms |
576 KB |
Output is correct |
38 |
Correct |
270 ms |
568 KB |
Output is correct |
39 |
Correct |
425 ms |
604 KB |
Output is correct |
40 |
Correct |
496 ms |
708 KB |
Output is correct |
41 |
Correct |
499 ms |
588 KB |
Output is correct |
42 |
Correct |
430 ms |
608 KB |
Output is correct |
43 |
Correct |
408 ms |
952 KB |
Output is correct |
44 |
Correct |
431 ms |
1092 KB |
Output is correct |
45 |
Correct |
430 ms |
964 KB |
Output is correct |
46 |
Correct |
484 ms |
488 KB |
Output is correct |
47 |
Correct |
427 ms |
624 KB |
Output is correct |
48 |
Correct |
430 ms |
856 KB |
Output is correct |
49 |
Correct |
444 ms |
604 KB |
Output is correct |
50 |
Correct |
421 ms |
632 KB |
Output is correct |
51 |
Correct |
2 ms |
332 KB |
Output is correct |
52 |
Correct |
510 ms |
1028 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
3 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
7 ms |
332 KB |
Output is correct |
11 |
Correct |
7 ms |
332 KB |
Output is correct |
12 |
Correct |
7 ms |
332 KB |
Output is correct |
13 |
Correct |
6 ms |
388 KB |
Output is correct |
14 |
Correct |
7 ms |
332 KB |
Output is correct |
15 |
Correct |
6 ms |
332 KB |
Output is correct |
16 |
Correct |
7 ms |
332 KB |
Output is correct |
17 |
Correct |
4 ms |
332 KB |
Output is correct |
18 |
Correct |
5 ms |
332 KB |
Output is correct |
19 |
Correct |
8 ms |
384 KB |
Output is correct |
20 |
Correct |
7 ms |
332 KB |
Output is correct |
21 |
Correct |
31 ms |
332 KB |
Output is correct |
22 |
Correct |
38 ms |
376 KB |
Output is correct |
23 |
Correct |
18 ms |
392 KB |
Output is correct |
24 |
Correct |
61 ms |
392 KB |
Output is correct |
25 |
Correct |
61 ms |
408 KB |
Output is correct |
26 |
Correct |
69 ms |
404 KB |
Output is correct |
27 |
Correct |
69 ms |
408 KB |
Output is correct |
28 |
Correct |
73 ms |
404 KB |
Output is correct |
29 |
Correct |
69 ms |
332 KB |
Output is correct |
30 |
Correct |
67 ms |
384 KB |
Output is correct |
31 |
Correct |
69 ms |
392 KB |
Output is correct |
32 |
Correct |
70 ms |
376 KB |
Output is correct |
33 |
Correct |
68 ms |
332 KB |
Output is correct |
34 |
Correct |
72 ms |
412 KB |
Output is correct |
35 |
Correct |
69 ms |
396 KB |
Output is correct |
36 |
Correct |
68 ms |
380 KB |
Output is correct |
37 |
Correct |
268 ms |
576 KB |
Output is correct |
38 |
Correct |
270 ms |
568 KB |
Output is correct |
39 |
Correct |
425 ms |
604 KB |
Output is correct |
40 |
Correct |
496 ms |
708 KB |
Output is correct |
41 |
Correct |
499 ms |
588 KB |
Output is correct |
42 |
Correct |
430 ms |
608 KB |
Output is correct |
43 |
Correct |
408 ms |
952 KB |
Output is correct |
44 |
Correct |
431 ms |
1092 KB |
Output is correct |
45 |
Correct |
430 ms |
964 KB |
Output is correct |
46 |
Correct |
484 ms |
488 KB |
Output is correct |
47 |
Correct |
427 ms |
624 KB |
Output is correct |
48 |
Correct |
430 ms |
856 KB |
Output is correct |
49 |
Correct |
444 ms |
604 KB |
Output is correct |
50 |
Correct |
421 ms |
632 KB |
Output is correct |
51 |
Correct |
2 ms |
332 KB |
Output is correct |
52 |
Correct |
510 ms |
1028 KB |
Output is correct |
53 |
Correct |
608 ms |
792 KB |
Output is correct |
54 |
Correct |
855 ms |
960 KB |
Output is correct |
55 |
Correct |
849 ms |
1304 KB |
Output is correct |
56 |
Correct |
649 ms |
964 KB |
Output is correct |
57 |
Correct |
842 ms |
1456 KB |
Output is correct |
58 |
Correct |
827 ms |
988 KB |
Output is correct |
59 |
Correct |
834 ms |
1048 KB |
Output is correct |
60 |
Correct |
4 ms |
380 KB |
Output is correct |
61 |
Correct |
848 ms |
1244 KB |
Output is correct |
62 |
Correct |
725 ms |
1240 KB |
Output is correct |
63 |
Correct |
726 ms |
1280 KB |
Output is correct |
64 |
Correct |
698 ms |
1276 KB |
Output is correct |
65 |
Correct |
679 ms |
552 KB |
Output is correct |
66 |
Correct |
666 ms |
700 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
3 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
7 ms |
332 KB |
Output is correct |
11 |
Correct |
7 ms |
332 KB |
Output is correct |
12 |
Correct |
7 ms |
332 KB |
Output is correct |
13 |
Correct |
6 ms |
388 KB |
Output is correct |
14 |
Correct |
7 ms |
332 KB |
Output is correct |
15 |
Correct |
6 ms |
332 KB |
Output is correct |
16 |
Correct |
7 ms |
332 KB |
Output is correct |
17 |
Correct |
4 ms |
332 KB |
Output is correct |
18 |
Correct |
5 ms |
332 KB |
Output is correct |
19 |
Correct |
8 ms |
384 KB |
Output is correct |
20 |
Correct |
7 ms |
332 KB |
Output is correct |
21 |
Correct |
31 ms |
332 KB |
Output is correct |
22 |
Correct |
38 ms |
376 KB |
Output is correct |
23 |
Correct |
18 ms |
392 KB |
Output is correct |
24 |
Correct |
61 ms |
392 KB |
Output is correct |
25 |
Correct |
61 ms |
408 KB |
Output is correct |
26 |
Correct |
69 ms |
404 KB |
Output is correct |
27 |
Correct |
69 ms |
408 KB |
Output is correct |
28 |
Correct |
73 ms |
404 KB |
Output is correct |
29 |
Correct |
69 ms |
332 KB |
Output is correct |
30 |
Correct |
67 ms |
384 KB |
Output is correct |
31 |
Correct |
69 ms |
392 KB |
Output is correct |
32 |
Correct |
70 ms |
376 KB |
Output is correct |
33 |
Correct |
68 ms |
332 KB |
Output is correct |
34 |
Correct |
72 ms |
412 KB |
Output is correct |
35 |
Correct |
69 ms |
396 KB |
Output is correct |
36 |
Correct |
68 ms |
380 KB |
Output is correct |
37 |
Correct |
268 ms |
576 KB |
Output is correct |
38 |
Correct |
270 ms |
568 KB |
Output is correct |
39 |
Correct |
425 ms |
604 KB |
Output is correct |
40 |
Correct |
496 ms |
708 KB |
Output is correct |
41 |
Correct |
499 ms |
588 KB |
Output is correct |
42 |
Correct |
430 ms |
608 KB |
Output is correct |
43 |
Correct |
408 ms |
952 KB |
Output is correct |
44 |
Correct |
431 ms |
1092 KB |
Output is correct |
45 |
Correct |
430 ms |
964 KB |
Output is correct |
46 |
Correct |
484 ms |
488 KB |
Output is correct |
47 |
Correct |
427 ms |
624 KB |
Output is correct |
48 |
Correct |
430 ms |
856 KB |
Output is correct |
49 |
Correct |
444 ms |
604 KB |
Output is correct |
50 |
Correct |
421 ms |
632 KB |
Output is correct |
51 |
Correct |
2 ms |
332 KB |
Output is correct |
52 |
Correct |
510 ms |
1028 KB |
Output is correct |
53 |
Correct |
608 ms |
792 KB |
Output is correct |
54 |
Correct |
855 ms |
960 KB |
Output is correct |
55 |
Correct |
849 ms |
1304 KB |
Output is correct |
56 |
Correct |
649 ms |
964 KB |
Output is correct |
57 |
Correct |
842 ms |
1456 KB |
Output is correct |
58 |
Correct |
827 ms |
988 KB |
Output is correct |
59 |
Correct |
834 ms |
1048 KB |
Output is correct |
60 |
Correct |
4 ms |
380 KB |
Output is correct |
61 |
Correct |
848 ms |
1244 KB |
Output is correct |
62 |
Correct |
725 ms |
1240 KB |
Output is correct |
63 |
Correct |
726 ms |
1280 KB |
Output is correct |
64 |
Correct |
698 ms |
1276 KB |
Output is correct |
65 |
Correct |
679 ms |
552 KB |
Output is correct |
66 |
Correct |
666 ms |
700 KB |
Output is correct |
67 |
Execution timed out |
1088 ms |
1184 KB |
Time limit exceeded |
68 |
Halted |
0 ms |
0 KB |
- |