#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define mp make_pair
using namespace std;
void db() {cout << endl;}
template <typename T, typename ...U> void db(T a, U ...b) {cout << a << ' ', db(b...);}
#ifdef Cloud
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#else
#define file ios::sync_with_stdio(false); cin.tie(0)
#endif
#define pii pair<int, int>
const int inf = 1e9, N = 250001, mod = 998244353;
int main(){
file;
int n;
cin >> n;
int a[n], tot = 0, cnt[N]{};
for (int &i : a) cin >> i, tot += i;
if (tot % 2) return cout << 0 << '\n', 0;
for (int s = -1; s < n; s++){
bitset<250001> dp;
dp[0] = 1;
for (int i = 0; i < n; i++){
if (i == s) continue;
dp |= dp << a[i];
//for (int j = 0; j <= 20; j++) db(i, j, dp[j]);
}
if (s == -1 and !dp[tot / 2]) return cout << 0 << '\n', 0;
if (s >= 0) for (int i = 0; i < N; i++){
if (dp[i] and i * 2 - tot + a[s] > 0) cnt[i * 2 - tot + a[s]]++;
}
}
vector<int> v;
for (int i = 1; i < N; i++) if (cnt[i] == n) v.push_back(i);
cout << v.size() << '\n';
for (int i : v) cout << i << ' ';
//db("ya");
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1356 KB |
Output is correct |
2 |
Correct |
4 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
1356 KB |
Output is correct |
4 |
Correct |
3 ms |
1356 KB |
Output is correct |
5 |
Correct |
6 ms |
1356 KB |
Output is correct |
6 |
Correct |
7 ms |
1376 KB |
Output is correct |
7 |
Correct |
6 ms |
1356 KB |
Output is correct |
8 |
Correct |
7 ms |
1376 KB |
Output is correct |
9 |
Correct |
8 ms |
1360 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1356 KB |
Output is correct |
2 |
Correct |
4 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
1356 KB |
Output is correct |
4 |
Correct |
3 ms |
1356 KB |
Output is correct |
5 |
Correct |
6 ms |
1356 KB |
Output is correct |
6 |
Correct |
7 ms |
1376 KB |
Output is correct |
7 |
Correct |
6 ms |
1356 KB |
Output is correct |
8 |
Correct |
7 ms |
1376 KB |
Output is correct |
9 |
Correct |
8 ms |
1360 KB |
Output is correct |
10 |
Correct |
28 ms |
1372 KB |
Output is correct |
11 |
Correct |
17 ms |
1364 KB |
Output is correct |
12 |
Correct |
25 ms |
1372 KB |
Output is correct |
13 |
Correct |
13 ms |
1372 KB |
Output is correct |
14 |
Correct |
14 ms |
1380 KB |
Output is correct |
15 |
Correct |
14 ms |
1356 KB |
Output is correct |
16 |
Correct |
16 ms |
1356 KB |
Output is correct |
17 |
Correct |
10 ms |
1376 KB |
Output is correct |
18 |
Correct |
16 ms |
1376 KB |
Output is correct |
19 |
Correct |
14 ms |
1376 KB |
Output is correct |
20 |
Correct |
16 ms |
1376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1356 KB |
Output is correct |
2 |
Correct |
4 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
1356 KB |
Output is correct |
4 |
Correct |
3 ms |
1356 KB |
Output is correct |
5 |
Correct |
6 ms |
1356 KB |
Output is correct |
6 |
Correct |
7 ms |
1376 KB |
Output is correct |
7 |
Correct |
6 ms |
1356 KB |
Output is correct |
8 |
Correct |
7 ms |
1376 KB |
Output is correct |
9 |
Correct |
8 ms |
1360 KB |
Output is correct |
10 |
Correct |
28 ms |
1372 KB |
Output is correct |
11 |
Correct |
17 ms |
1364 KB |
Output is correct |
12 |
Correct |
25 ms |
1372 KB |
Output is correct |
13 |
Correct |
13 ms |
1372 KB |
Output is correct |
14 |
Correct |
14 ms |
1380 KB |
Output is correct |
15 |
Correct |
14 ms |
1356 KB |
Output is correct |
16 |
Correct |
16 ms |
1356 KB |
Output is correct |
17 |
Correct |
10 ms |
1376 KB |
Output is correct |
18 |
Correct |
16 ms |
1376 KB |
Output is correct |
19 |
Correct |
14 ms |
1376 KB |
Output is correct |
20 |
Correct |
16 ms |
1376 KB |
Output is correct |
21 |
Correct |
47 ms |
1356 KB |
Output is correct |
22 |
Correct |
58 ms |
1356 KB |
Output is correct |
23 |
Correct |
32 ms |
1368 KB |
Output is correct |
24 |
Correct |
97 ms |
1356 KB |
Output is correct |
25 |
Correct |
125 ms |
1360 KB |
Output is correct |
26 |
Correct |
103 ms |
1356 KB |
Output is correct |
27 |
Correct |
97 ms |
1356 KB |
Output is correct |
28 |
Correct |
96 ms |
1356 KB |
Output is correct |
29 |
Correct |
127 ms |
1356 KB |
Output is correct |
30 |
Correct |
95 ms |
1356 KB |
Output is correct |
31 |
Correct |
100 ms |
1356 KB |
Output is correct |
32 |
Correct |
97 ms |
1356 KB |
Output is correct |
33 |
Correct |
111 ms |
1356 KB |
Output is correct |
34 |
Correct |
143 ms |
1356 KB |
Output is correct |
35 |
Correct |
109 ms |
1356 KB |
Output is correct |
36 |
Correct |
117 ms |
1356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1356 KB |
Output is correct |
2 |
Correct |
4 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
1356 KB |
Output is correct |
4 |
Correct |
3 ms |
1356 KB |
Output is correct |
5 |
Correct |
6 ms |
1356 KB |
Output is correct |
6 |
Correct |
7 ms |
1376 KB |
Output is correct |
7 |
Correct |
6 ms |
1356 KB |
Output is correct |
8 |
Correct |
7 ms |
1376 KB |
Output is correct |
9 |
Correct |
8 ms |
1360 KB |
Output is correct |
10 |
Correct |
28 ms |
1372 KB |
Output is correct |
11 |
Correct |
17 ms |
1364 KB |
Output is correct |
12 |
Correct |
25 ms |
1372 KB |
Output is correct |
13 |
Correct |
13 ms |
1372 KB |
Output is correct |
14 |
Correct |
14 ms |
1380 KB |
Output is correct |
15 |
Correct |
14 ms |
1356 KB |
Output is correct |
16 |
Correct |
16 ms |
1356 KB |
Output is correct |
17 |
Correct |
10 ms |
1376 KB |
Output is correct |
18 |
Correct |
16 ms |
1376 KB |
Output is correct |
19 |
Correct |
14 ms |
1376 KB |
Output is correct |
20 |
Correct |
16 ms |
1376 KB |
Output is correct |
21 |
Correct |
47 ms |
1356 KB |
Output is correct |
22 |
Correct |
58 ms |
1356 KB |
Output is correct |
23 |
Correct |
32 ms |
1368 KB |
Output is correct |
24 |
Correct |
97 ms |
1356 KB |
Output is correct |
25 |
Correct |
125 ms |
1360 KB |
Output is correct |
26 |
Correct |
103 ms |
1356 KB |
Output is correct |
27 |
Correct |
97 ms |
1356 KB |
Output is correct |
28 |
Correct |
96 ms |
1356 KB |
Output is correct |
29 |
Correct |
127 ms |
1356 KB |
Output is correct |
30 |
Correct |
95 ms |
1356 KB |
Output is correct |
31 |
Correct |
100 ms |
1356 KB |
Output is correct |
32 |
Correct |
97 ms |
1356 KB |
Output is correct |
33 |
Correct |
111 ms |
1356 KB |
Output is correct |
34 |
Correct |
143 ms |
1356 KB |
Output is correct |
35 |
Correct |
109 ms |
1356 KB |
Output is correct |
36 |
Correct |
117 ms |
1356 KB |
Output is correct |
37 |
Correct |
400 ms |
1496 KB |
Output is correct |
38 |
Correct |
336 ms |
1480 KB |
Output is correct |
39 |
Correct |
572 ms |
1356 KB |
Output is correct |
40 |
Correct |
654 ms |
1484 KB |
Output is correct |
41 |
Correct |
594 ms |
1356 KB |
Output is correct |
42 |
Correct |
613 ms |
1508 KB |
Output is correct |
43 |
Correct |
468 ms |
1736 KB |
Output is correct |
44 |
Correct |
582 ms |
1640 KB |
Output is correct |
45 |
Correct |
537 ms |
1740 KB |
Output is correct |
46 |
Correct |
700 ms |
1356 KB |
Output is correct |
47 |
Correct |
564 ms |
1484 KB |
Output is correct |
48 |
Correct |
575 ms |
1608 KB |
Output is correct |
49 |
Correct |
561 ms |
1356 KB |
Output is correct |
50 |
Correct |
518 ms |
1484 KB |
Output is correct |
51 |
Correct |
1 ms |
1356 KB |
Output is correct |
52 |
Correct |
615 ms |
1736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1356 KB |
Output is correct |
2 |
Correct |
4 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
1356 KB |
Output is correct |
4 |
Correct |
3 ms |
1356 KB |
Output is correct |
5 |
Correct |
6 ms |
1356 KB |
Output is correct |
6 |
Correct |
7 ms |
1376 KB |
Output is correct |
7 |
Correct |
6 ms |
1356 KB |
Output is correct |
8 |
Correct |
7 ms |
1376 KB |
Output is correct |
9 |
Correct |
8 ms |
1360 KB |
Output is correct |
10 |
Correct |
28 ms |
1372 KB |
Output is correct |
11 |
Correct |
17 ms |
1364 KB |
Output is correct |
12 |
Correct |
25 ms |
1372 KB |
Output is correct |
13 |
Correct |
13 ms |
1372 KB |
Output is correct |
14 |
Correct |
14 ms |
1380 KB |
Output is correct |
15 |
Correct |
14 ms |
1356 KB |
Output is correct |
16 |
Correct |
16 ms |
1356 KB |
Output is correct |
17 |
Correct |
10 ms |
1376 KB |
Output is correct |
18 |
Correct |
16 ms |
1376 KB |
Output is correct |
19 |
Correct |
14 ms |
1376 KB |
Output is correct |
20 |
Correct |
16 ms |
1376 KB |
Output is correct |
21 |
Correct |
47 ms |
1356 KB |
Output is correct |
22 |
Correct |
58 ms |
1356 KB |
Output is correct |
23 |
Correct |
32 ms |
1368 KB |
Output is correct |
24 |
Correct |
97 ms |
1356 KB |
Output is correct |
25 |
Correct |
125 ms |
1360 KB |
Output is correct |
26 |
Correct |
103 ms |
1356 KB |
Output is correct |
27 |
Correct |
97 ms |
1356 KB |
Output is correct |
28 |
Correct |
96 ms |
1356 KB |
Output is correct |
29 |
Correct |
127 ms |
1356 KB |
Output is correct |
30 |
Correct |
95 ms |
1356 KB |
Output is correct |
31 |
Correct |
100 ms |
1356 KB |
Output is correct |
32 |
Correct |
97 ms |
1356 KB |
Output is correct |
33 |
Correct |
111 ms |
1356 KB |
Output is correct |
34 |
Correct |
143 ms |
1356 KB |
Output is correct |
35 |
Correct |
109 ms |
1356 KB |
Output is correct |
36 |
Correct |
117 ms |
1356 KB |
Output is correct |
37 |
Correct |
400 ms |
1496 KB |
Output is correct |
38 |
Correct |
336 ms |
1480 KB |
Output is correct |
39 |
Correct |
572 ms |
1356 KB |
Output is correct |
40 |
Correct |
654 ms |
1484 KB |
Output is correct |
41 |
Correct |
594 ms |
1356 KB |
Output is correct |
42 |
Correct |
613 ms |
1508 KB |
Output is correct |
43 |
Correct |
468 ms |
1736 KB |
Output is correct |
44 |
Correct |
582 ms |
1640 KB |
Output is correct |
45 |
Correct |
537 ms |
1740 KB |
Output is correct |
46 |
Correct |
700 ms |
1356 KB |
Output is correct |
47 |
Correct |
564 ms |
1484 KB |
Output is correct |
48 |
Correct |
575 ms |
1608 KB |
Output is correct |
49 |
Correct |
561 ms |
1356 KB |
Output is correct |
50 |
Correct |
518 ms |
1484 KB |
Output is correct |
51 |
Correct |
1 ms |
1356 KB |
Output is correct |
52 |
Correct |
615 ms |
1736 KB |
Output is correct |
53 |
Correct |
788 ms |
1616 KB |
Output is correct |
54 |
Execution timed out |
1040 ms |
1740 KB |
Time limit exceeded |
55 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1356 KB |
Output is correct |
2 |
Correct |
4 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
1356 KB |
Output is correct |
4 |
Correct |
3 ms |
1356 KB |
Output is correct |
5 |
Correct |
6 ms |
1356 KB |
Output is correct |
6 |
Correct |
7 ms |
1376 KB |
Output is correct |
7 |
Correct |
6 ms |
1356 KB |
Output is correct |
8 |
Correct |
7 ms |
1376 KB |
Output is correct |
9 |
Correct |
8 ms |
1360 KB |
Output is correct |
10 |
Correct |
28 ms |
1372 KB |
Output is correct |
11 |
Correct |
17 ms |
1364 KB |
Output is correct |
12 |
Correct |
25 ms |
1372 KB |
Output is correct |
13 |
Correct |
13 ms |
1372 KB |
Output is correct |
14 |
Correct |
14 ms |
1380 KB |
Output is correct |
15 |
Correct |
14 ms |
1356 KB |
Output is correct |
16 |
Correct |
16 ms |
1356 KB |
Output is correct |
17 |
Correct |
10 ms |
1376 KB |
Output is correct |
18 |
Correct |
16 ms |
1376 KB |
Output is correct |
19 |
Correct |
14 ms |
1376 KB |
Output is correct |
20 |
Correct |
16 ms |
1376 KB |
Output is correct |
21 |
Correct |
47 ms |
1356 KB |
Output is correct |
22 |
Correct |
58 ms |
1356 KB |
Output is correct |
23 |
Correct |
32 ms |
1368 KB |
Output is correct |
24 |
Correct |
97 ms |
1356 KB |
Output is correct |
25 |
Correct |
125 ms |
1360 KB |
Output is correct |
26 |
Correct |
103 ms |
1356 KB |
Output is correct |
27 |
Correct |
97 ms |
1356 KB |
Output is correct |
28 |
Correct |
96 ms |
1356 KB |
Output is correct |
29 |
Correct |
127 ms |
1356 KB |
Output is correct |
30 |
Correct |
95 ms |
1356 KB |
Output is correct |
31 |
Correct |
100 ms |
1356 KB |
Output is correct |
32 |
Correct |
97 ms |
1356 KB |
Output is correct |
33 |
Correct |
111 ms |
1356 KB |
Output is correct |
34 |
Correct |
143 ms |
1356 KB |
Output is correct |
35 |
Correct |
109 ms |
1356 KB |
Output is correct |
36 |
Correct |
117 ms |
1356 KB |
Output is correct |
37 |
Correct |
400 ms |
1496 KB |
Output is correct |
38 |
Correct |
336 ms |
1480 KB |
Output is correct |
39 |
Correct |
572 ms |
1356 KB |
Output is correct |
40 |
Correct |
654 ms |
1484 KB |
Output is correct |
41 |
Correct |
594 ms |
1356 KB |
Output is correct |
42 |
Correct |
613 ms |
1508 KB |
Output is correct |
43 |
Correct |
468 ms |
1736 KB |
Output is correct |
44 |
Correct |
582 ms |
1640 KB |
Output is correct |
45 |
Correct |
537 ms |
1740 KB |
Output is correct |
46 |
Correct |
700 ms |
1356 KB |
Output is correct |
47 |
Correct |
564 ms |
1484 KB |
Output is correct |
48 |
Correct |
575 ms |
1608 KB |
Output is correct |
49 |
Correct |
561 ms |
1356 KB |
Output is correct |
50 |
Correct |
518 ms |
1484 KB |
Output is correct |
51 |
Correct |
1 ms |
1356 KB |
Output is correct |
52 |
Correct |
615 ms |
1736 KB |
Output is correct |
53 |
Correct |
788 ms |
1616 KB |
Output is correct |
54 |
Execution timed out |
1040 ms |
1740 KB |
Time limit exceeded |
55 |
Halted |
0 ms |
0 KB |
- |