#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long
#define mod 1000000007
ofstream fout(".out");
ifstream fin(".in");
int b[250001], gg[501][250001];
signed main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
int arr[n];
int sum = 0;
for(int i = 0; i < n; i++) {
cin >> arr[i];
sum += arr[i];
}
for(int k = 0; k < n; k++) {
for(int i = 0; i < sum; i++)
b[i] = 0;
swap(arr[k], arr[n - 1]);
b[0] = 1;
for(int i = 0; i < n; i++) {
for(int j = sum; j >= arr[i]; j--) {
b[j] += b[j - arr[i]];
if(i == n - 1)
gg[k][j] = b[j - arr[i]];
}
}
swap(arr[k], arr[n - 1]);
}
if(sum % 2 || !b[sum / 2]) {
cout << 0;
return 0;
}
vector<int> ans;
for(int i = 1; i <= sum; i++) {
bool bb = 1;
for(int j = 0; j < n; j++) {
int x = sum - arr[j] + i;
if(i % 2 != arr[j] % 2 || x < 0 || !(b[x / 2] - gg[j][x / 2])) {
bb = 0;
break;
}
}
if(bb)
ans.push_back(i);
}
cout << ans.size() << "\n";
for(int i : ans)
cout << i << " ";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
9 ms |
1492 KB |
Output is correct |
22 |
Correct |
12 ms |
1748 KB |
Output is correct |
23 |
Correct |
4 ms |
1108 KB |
Output is correct |
24 |
Correct |
26 ms |
2520 KB |
Output is correct |
25 |
Correct |
46 ms |
4152 KB |
Output is correct |
26 |
Correct |
57 ms |
4664 KB |
Output is correct |
27 |
Correct |
71 ms |
4336 KB |
Output is correct |
28 |
Correct |
61 ms |
4560 KB |
Output is correct |
29 |
Correct |
57 ms |
4740 KB |
Output is correct |
30 |
Correct |
30 ms |
2924 KB |
Output is correct |
31 |
Correct |
48 ms |
3856 KB |
Output is correct |
32 |
Correct |
27 ms |
2764 KB |
Output is correct |
33 |
Correct |
57 ms |
4808 KB |
Output is correct |
34 |
Correct |
55 ms |
4732 KB |
Output is correct |
35 |
Correct |
66 ms |
4684 KB |
Output is correct |
36 |
Correct |
32 ms |
2768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
9 ms |
1492 KB |
Output is correct |
22 |
Correct |
12 ms |
1748 KB |
Output is correct |
23 |
Correct |
4 ms |
1108 KB |
Output is correct |
24 |
Correct |
26 ms |
2520 KB |
Output is correct |
25 |
Correct |
46 ms |
4152 KB |
Output is correct |
26 |
Correct |
57 ms |
4664 KB |
Output is correct |
27 |
Correct |
71 ms |
4336 KB |
Output is correct |
28 |
Correct |
61 ms |
4560 KB |
Output is correct |
29 |
Correct |
57 ms |
4740 KB |
Output is correct |
30 |
Correct |
30 ms |
2924 KB |
Output is correct |
31 |
Correct |
48 ms |
3856 KB |
Output is correct |
32 |
Correct |
27 ms |
2764 KB |
Output is correct |
33 |
Correct |
57 ms |
4808 KB |
Output is correct |
34 |
Correct |
55 ms |
4732 KB |
Output is correct |
35 |
Correct |
66 ms |
4684 KB |
Output is correct |
36 |
Correct |
32 ms |
2768 KB |
Output is correct |
37 |
Correct |
443 ms |
16836 KB |
Output is correct |
38 |
Correct |
481 ms |
17156 KB |
Output is correct |
39 |
Execution timed out |
1094 ms |
31332 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
9 ms |
1492 KB |
Output is correct |
22 |
Correct |
12 ms |
1748 KB |
Output is correct |
23 |
Correct |
4 ms |
1108 KB |
Output is correct |
24 |
Correct |
26 ms |
2520 KB |
Output is correct |
25 |
Correct |
46 ms |
4152 KB |
Output is correct |
26 |
Correct |
57 ms |
4664 KB |
Output is correct |
27 |
Correct |
71 ms |
4336 KB |
Output is correct |
28 |
Correct |
61 ms |
4560 KB |
Output is correct |
29 |
Correct |
57 ms |
4740 KB |
Output is correct |
30 |
Correct |
30 ms |
2924 KB |
Output is correct |
31 |
Correct |
48 ms |
3856 KB |
Output is correct |
32 |
Correct |
27 ms |
2764 KB |
Output is correct |
33 |
Correct |
57 ms |
4808 KB |
Output is correct |
34 |
Correct |
55 ms |
4732 KB |
Output is correct |
35 |
Correct |
66 ms |
4684 KB |
Output is correct |
36 |
Correct |
32 ms |
2768 KB |
Output is correct |
37 |
Correct |
443 ms |
16836 KB |
Output is correct |
38 |
Correct |
481 ms |
17156 KB |
Output is correct |
39 |
Execution timed out |
1094 ms |
31332 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
9 ms |
1492 KB |
Output is correct |
22 |
Correct |
12 ms |
1748 KB |
Output is correct |
23 |
Correct |
4 ms |
1108 KB |
Output is correct |
24 |
Correct |
26 ms |
2520 KB |
Output is correct |
25 |
Correct |
46 ms |
4152 KB |
Output is correct |
26 |
Correct |
57 ms |
4664 KB |
Output is correct |
27 |
Correct |
71 ms |
4336 KB |
Output is correct |
28 |
Correct |
61 ms |
4560 KB |
Output is correct |
29 |
Correct |
57 ms |
4740 KB |
Output is correct |
30 |
Correct |
30 ms |
2924 KB |
Output is correct |
31 |
Correct |
48 ms |
3856 KB |
Output is correct |
32 |
Correct |
27 ms |
2764 KB |
Output is correct |
33 |
Correct |
57 ms |
4808 KB |
Output is correct |
34 |
Correct |
55 ms |
4732 KB |
Output is correct |
35 |
Correct |
66 ms |
4684 KB |
Output is correct |
36 |
Correct |
32 ms |
2768 KB |
Output is correct |
37 |
Correct |
443 ms |
16836 KB |
Output is correct |
38 |
Correct |
481 ms |
17156 KB |
Output is correct |
39 |
Execution timed out |
1094 ms |
31332 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |