#include <bits/stdc++.h>
#define all(X) X.begin(), X.end()
#define sz(x) (int)x.size()
#define fr first
#define sc second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int maxn = 250001;
const int maxa = 1e6;
const int inf = 2e9;
const ll INF = 1e18;
const ll mod = 1e9 + 7;
const int block = 350;
int main ()
{
ios_base::sync_with_stdio(0); cin.tie();
/*#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif*/
int n; cin >> n;
vector <int> a (n);
int mx = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
mx = max(mx, a[i]);
}
bitset <maxn> st;
int sum = 0;
st[0] = 1;
for (int i = 0; i < n; i++) {
st |= (st << a[i]);
sum += a[i];
}
if (sum % 2 == 1 || !st[sum >> 1]) {
cout << 0;
return 0;
}
vector <int> used (maxn);
for (int i = 0; i < n; i++) {
bitset <maxn> dp;
dp[0] = 1;
int cur_sum = 0;
for (int j = 0; j < n; j++) {
if (i != j) {
dp |= (dp << a[j]);
cur_sum += a[j];
}
}
for (int ins = 1; ins < maxn; ins++) {
if ((cur_sum + ins) % 2 == 0 && dp[(cur_sum + ins) >> 1]) {
used[ins]++;
}
}
}
vector <int> ans;
for (int i = 0; i < maxn; i++) {
if (used[i] == n) {
ans.push_back(i);
}
}
cout << sz(ans) << endl;
for (auto i : ans) {
cout << i << " ";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1356 KB |
Output is correct |
2 |
Correct |
5 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
5 ms |
1356 KB |
Output is correct |
5 |
Correct |
10 ms |
1356 KB |
Output is correct |
6 |
Correct |
6 ms |
1356 KB |
Output is correct |
7 |
Correct |
5 ms |
1356 KB |
Output is correct |
8 |
Correct |
8 ms |
1356 KB |
Output is correct |
9 |
Correct |
7 ms |
1356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1356 KB |
Output is correct |
2 |
Correct |
5 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
5 ms |
1356 KB |
Output is correct |
5 |
Correct |
10 ms |
1356 KB |
Output is correct |
6 |
Correct |
6 ms |
1356 KB |
Output is correct |
7 |
Correct |
5 ms |
1356 KB |
Output is correct |
8 |
Correct |
8 ms |
1356 KB |
Output is correct |
9 |
Correct |
7 ms |
1356 KB |
Output is correct |
10 |
Correct |
22 ms |
1356 KB |
Output is correct |
11 |
Correct |
23 ms |
1356 KB |
Output is correct |
12 |
Correct |
25 ms |
1356 KB |
Output is correct |
13 |
Correct |
21 ms |
1356 KB |
Output is correct |
14 |
Correct |
21 ms |
1356 KB |
Output is correct |
15 |
Correct |
23 ms |
1356 KB |
Output is correct |
16 |
Correct |
26 ms |
1356 KB |
Output is correct |
17 |
Correct |
14 ms |
1356 KB |
Output is correct |
18 |
Correct |
21 ms |
1356 KB |
Output is correct |
19 |
Correct |
19 ms |
1356 KB |
Output is correct |
20 |
Correct |
23 ms |
1356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1356 KB |
Output is correct |
2 |
Correct |
5 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
5 ms |
1356 KB |
Output is correct |
5 |
Correct |
10 ms |
1356 KB |
Output is correct |
6 |
Correct |
6 ms |
1356 KB |
Output is correct |
7 |
Correct |
5 ms |
1356 KB |
Output is correct |
8 |
Correct |
8 ms |
1356 KB |
Output is correct |
9 |
Correct |
7 ms |
1356 KB |
Output is correct |
10 |
Correct |
22 ms |
1356 KB |
Output is correct |
11 |
Correct |
23 ms |
1356 KB |
Output is correct |
12 |
Correct |
25 ms |
1356 KB |
Output is correct |
13 |
Correct |
21 ms |
1356 KB |
Output is correct |
14 |
Correct |
21 ms |
1356 KB |
Output is correct |
15 |
Correct |
23 ms |
1356 KB |
Output is correct |
16 |
Correct |
26 ms |
1356 KB |
Output is correct |
17 |
Correct |
14 ms |
1356 KB |
Output is correct |
18 |
Correct |
21 ms |
1356 KB |
Output is correct |
19 |
Correct |
19 ms |
1356 KB |
Output is correct |
20 |
Correct |
23 ms |
1356 KB |
Output is correct |
21 |
Correct |
78 ms |
1412 KB |
Output is correct |
22 |
Correct |
108 ms |
1404 KB |
Output is correct |
23 |
Correct |
47 ms |
1356 KB |
Output is correct |
24 |
Correct |
130 ms |
1412 KB |
Output is correct |
25 |
Correct |
125 ms |
1408 KB |
Output is correct |
26 |
Correct |
168 ms |
1412 KB |
Output is correct |
27 |
Correct |
151 ms |
1404 KB |
Output is correct |
28 |
Correct |
141 ms |
1356 KB |
Output is correct |
29 |
Correct |
157 ms |
1396 KB |
Output is correct |
30 |
Correct |
143 ms |
1356 KB |
Output is correct |
31 |
Correct |
144 ms |
1412 KB |
Output is correct |
32 |
Correct |
153 ms |
1376 KB |
Output is correct |
33 |
Correct |
156 ms |
1356 KB |
Output is correct |
34 |
Correct |
139 ms |
1356 KB |
Output is correct |
35 |
Correct |
144 ms |
1356 KB |
Output is correct |
36 |
Correct |
148 ms |
1404 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1356 KB |
Output is correct |
2 |
Correct |
5 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
5 ms |
1356 KB |
Output is correct |
5 |
Correct |
10 ms |
1356 KB |
Output is correct |
6 |
Correct |
6 ms |
1356 KB |
Output is correct |
7 |
Correct |
5 ms |
1356 KB |
Output is correct |
8 |
Correct |
8 ms |
1356 KB |
Output is correct |
9 |
Correct |
7 ms |
1356 KB |
Output is correct |
10 |
Correct |
22 ms |
1356 KB |
Output is correct |
11 |
Correct |
23 ms |
1356 KB |
Output is correct |
12 |
Correct |
25 ms |
1356 KB |
Output is correct |
13 |
Correct |
21 ms |
1356 KB |
Output is correct |
14 |
Correct |
21 ms |
1356 KB |
Output is correct |
15 |
Correct |
23 ms |
1356 KB |
Output is correct |
16 |
Correct |
26 ms |
1356 KB |
Output is correct |
17 |
Correct |
14 ms |
1356 KB |
Output is correct |
18 |
Correct |
21 ms |
1356 KB |
Output is correct |
19 |
Correct |
19 ms |
1356 KB |
Output is correct |
20 |
Correct |
23 ms |
1356 KB |
Output is correct |
21 |
Correct |
78 ms |
1412 KB |
Output is correct |
22 |
Correct |
108 ms |
1404 KB |
Output is correct |
23 |
Correct |
47 ms |
1356 KB |
Output is correct |
24 |
Correct |
130 ms |
1412 KB |
Output is correct |
25 |
Correct |
125 ms |
1408 KB |
Output is correct |
26 |
Correct |
168 ms |
1412 KB |
Output is correct |
27 |
Correct |
151 ms |
1404 KB |
Output is correct |
28 |
Correct |
141 ms |
1356 KB |
Output is correct |
29 |
Correct |
157 ms |
1396 KB |
Output is correct |
30 |
Correct |
143 ms |
1356 KB |
Output is correct |
31 |
Correct |
144 ms |
1412 KB |
Output is correct |
32 |
Correct |
153 ms |
1376 KB |
Output is correct |
33 |
Correct |
156 ms |
1356 KB |
Output is correct |
34 |
Correct |
139 ms |
1356 KB |
Output is correct |
35 |
Correct |
144 ms |
1356 KB |
Output is correct |
36 |
Correct |
148 ms |
1404 KB |
Output is correct |
37 |
Correct |
490 ms |
1548 KB |
Output is correct |
38 |
Correct |
499 ms |
1528 KB |
Output is correct |
39 |
Correct |
736 ms |
1400 KB |
Output is correct |
40 |
Correct |
856 ms |
1544 KB |
Output is correct |
41 |
Correct |
836 ms |
1356 KB |
Output is correct |
42 |
Correct |
744 ms |
1604 KB |
Output is correct |
43 |
Correct |
698 ms |
1784 KB |
Output is correct |
44 |
Correct |
762 ms |
1788 KB |
Output is correct |
45 |
Correct |
740 ms |
1732 KB |
Output is correct |
46 |
Correct |
853 ms |
1356 KB |
Output is correct |
47 |
Correct |
745 ms |
1572 KB |
Output is correct |
48 |
Correct |
743 ms |
1732 KB |
Output is correct |
49 |
Correct |
748 ms |
1404 KB |
Output is correct |
50 |
Correct |
762 ms |
1536 KB |
Output is correct |
51 |
Correct |
3 ms |
332 KB |
Output is correct |
52 |
Correct |
890 ms |
1788 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1356 KB |
Output is correct |
2 |
Correct |
5 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
5 ms |
1356 KB |
Output is correct |
5 |
Correct |
10 ms |
1356 KB |
Output is correct |
6 |
Correct |
6 ms |
1356 KB |
Output is correct |
7 |
Correct |
5 ms |
1356 KB |
Output is correct |
8 |
Correct |
8 ms |
1356 KB |
Output is correct |
9 |
Correct |
7 ms |
1356 KB |
Output is correct |
10 |
Correct |
22 ms |
1356 KB |
Output is correct |
11 |
Correct |
23 ms |
1356 KB |
Output is correct |
12 |
Correct |
25 ms |
1356 KB |
Output is correct |
13 |
Correct |
21 ms |
1356 KB |
Output is correct |
14 |
Correct |
21 ms |
1356 KB |
Output is correct |
15 |
Correct |
23 ms |
1356 KB |
Output is correct |
16 |
Correct |
26 ms |
1356 KB |
Output is correct |
17 |
Correct |
14 ms |
1356 KB |
Output is correct |
18 |
Correct |
21 ms |
1356 KB |
Output is correct |
19 |
Correct |
19 ms |
1356 KB |
Output is correct |
20 |
Correct |
23 ms |
1356 KB |
Output is correct |
21 |
Correct |
78 ms |
1412 KB |
Output is correct |
22 |
Correct |
108 ms |
1404 KB |
Output is correct |
23 |
Correct |
47 ms |
1356 KB |
Output is correct |
24 |
Correct |
130 ms |
1412 KB |
Output is correct |
25 |
Correct |
125 ms |
1408 KB |
Output is correct |
26 |
Correct |
168 ms |
1412 KB |
Output is correct |
27 |
Correct |
151 ms |
1404 KB |
Output is correct |
28 |
Correct |
141 ms |
1356 KB |
Output is correct |
29 |
Correct |
157 ms |
1396 KB |
Output is correct |
30 |
Correct |
143 ms |
1356 KB |
Output is correct |
31 |
Correct |
144 ms |
1412 KB |
Output is correct |
32 |
Correct |
153 ms |
1376 KB |
Output is correct |
33 |
Correct |
156 ms |
1356 KB |
Output is correct |
34 |
Correct |
139 ms |
1356 KB |
Output is correct |
35 |
Correct |
144 ms |
1356 KB |
Output is correct |
36 |
Correct |
148 ms |
1404 KB |
Output is correct |
37 |
Correct |
490 ms |
1548 KB |
Output is correct |
38 |
Correct |
499 ms |
1528 KB |
Output is correct |
39 |
Correct |
736 ms |
1400 KB |
Output is correct |
40 |
Correct |
856 ms |
1544 KB |
Output is correct |
41 |
Correct |
836 ms |
1356 KB |
Output is correct |
42 |
Correct |
744 ms |
1604 KB |
Output is correct |
43 |
Correct |
698 ms |
1784 KB |
Output is correct |
44 |
Correct |
762 ms |
1788 KB |
Output is correct |
45 |
Correct |
740 ms |
1732 KB |
Output is correct |
46 |
Correct |
853 ms |
1356 KB |
Output is correct |
47 |
Correct |
745 ms |
1572 KB |
Output is correct |
48 |
Correct |
743 ms |
1732 KB |
Output is correct |
49 |
Correct |
748 ms |
1404 KB |
Output is correct |
50 |
Correct |
762 ms |
1536 KB |
Output is correct |
51 |
Correct |
3 ms |
332 KB |
Output is correct |
52 |
Correct |
890 ms |
1788 KB |
Output is correct |
53 |
Execution timed out |
1044 ms |
1672 KB |
Time limit exceeded |
54 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1356 KB |
Output is correct |
2 |
Correct |
5 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
5 ms |
1356 KB |
Output is correct |
5 |
Correct |
10 ms |
1356 KB |
Output is correct |
6 |
Correct |
6 ms |
1356 KB |
Output is correct |
7 |
Correct |
5 ms |
1356 KB |
Output is correct |
8 |
Correct |
8 ms |
1356 KB |
Output is correct |
9 |
Correct |
7 ms |
1356 KB |
Output is correct |
10 |
Correct |
22 ms |
1356 KB |
Output is correct |
11 |
Correct |
23 ms |
1356 KB |
Output is correct |
12 |
Correct |
25 ms |
1356 KB |
Output is correct |
13 |
Correct |
21 ms |
1356 KB |
Output is correct |
14 |
Correct |
21 ms |
1356 KB |
Output is correct |
15 |
Correct |
23 ms |
1356 KB |
Output is correct |
16 |
Correct |
26 ms |
1356 KB |
Output is correct |
17 |
Correct |
14 ms |
1356 KB |
Output is correct |
18 |
Correct |
21 ms |
1356 KB |
Output is correct |
19 |
Correct |
19 ms |
1356 KB |
Output is correct |
20 |
Correct |
23 ms |
1356 KB |
Output is correct |
21 |
Correct |
78 ms |
1412 KB |
Output is correct |
22 |
Correct |
108 ms |
1404 KB |
Output is correct |
23 |
Correct |
47 ms |
1356 KB |
Output is correct |
24 |
Correct |
130 ms |
1412 KB |
Output is correct |
25 |
Correct |
125 ms |
1408 KB |
Output is correct |
26 |
Correct |
168 ms |
1412 KB |
Output is correct |
27 |
Correct |
151 ms |
1404 KB |
Output is correct |
28 |
Correct |
141 ms |
1356 KB |
Output is correct |
29 |
Correct |
157 ms |
1396 KB |
Output is correct |
30 |
Correct |
143 ms |
1356 KB |
Output is correct |
31 |
Correct |
144 ms |
1412 KB |
Output is correct |
32 |
Correct |
153 ms |
1376 KB |
Output is correct |
33 |
Correct |
156 ms |
1356 KB |
Output is correct |
34 |
Correct |
139 ms |
1356 KB |
Output is correct |
35 |
Correct |
144 ms |
1356 KB |
Output is correct |
36 |
Correct |
148 ms |
1404 KB |
Output is correct |
37 |
Correct |
490 ms |
1548 KB |
Output is correct |
38 |
Correct |
499 ms |
1528 KB |
Output is correct |
39 |
Correct |
736 ms |
1400 KB |
Output is correct |
40 |
Correct |
856 ms |
1544 KB |
Output is correct |
41 |
Correct |
836 ms |
1356 KB |
Output is correct |
42 |
Correct |
744 ms |
1604 KB |
Output is correct |
43 |
Correct |
698 ms |
1784 KB |
Output is correct |
44 |
Correct |
762 ms |
1788 KB |
Output is correct |
45 |
Correct |
740 ms |
1732 KB |
Output is correct |
46 |
Correct |
853 ms |
1356 KB |
Output is correct |
47 |
Correct |
745 ms |
1572 KB |
Output is correct |
48 |
Correct |
743 ms |
1732 KB |
Output is correct |
49 |
Correct |
748 ms |
1404 KB |
Output is correct |
50 |
Correct |
762 ms |
1536 KB |
Output is correct |
51 |
Correct |
3 ms |
332 KB |
Output is correct |
52 |
Correct |
890 ms |
1788 KB |
Output is correct |
53 |
Execution timed out |
1044 ms |
1672 KB |
Time limit exceeded |
54 |
Halted |
0 ms |
0 KB |
- |