#include <bits/stdc++.h>
using namespace std;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;
const int MOD3 = 999990011;
const int MOD4 = 1e9 + 9;
template<unsigned int MOD>
struct mint {
int v;
mint() {}
mint(long long val) : v(val - (val >= MOD) * MOD + (val < 0) * MOD) {}
mint<MOD>& operator += (mint<MOD> other) {
*this = mint(v + other.v);
return *this;
}
mint<MOD>& operator -= (mint<MOD> other) {
*this = mint(v - other.v);
return *this;
}
};
const int N = 550;
const int A = 250000;
mint<MOD1> dp1[A]{1};
mint<MOD2> dp2[A]{1};
mint<MOD3> dp3[A]{1};
// mint<MOD4> dp4[A]{1};
int sum = 0;
void add(int val) {
sum += val;
for (int i = A - 1; i >= val; i--) {
dp1[i] += dp1[i - val];
dp2[i] += dp2[i - val];
dp3[i] += dp3[i - val];
// dp4[i] += dp4[i - val];
}
}
bool check(int sum) {
assert(0 <= sum && sum < A);
bool flag = true;
flag &= (dp1[sum].v > 0);
flag &= (dp2[sum].v > 0);
flag &= (dp3[sum].v > 0);
// flag &= (dp4[sum].v > 0);
return flag;
}
void del(int val) {
sum -= val;
for (int i = val; i < A; i++) {
dp1[i] -= dp1[i - val];
dp2[i] -= dp2[i - val];
dp3[i] -= dp3[i - val];
// dp4[i] -= dp4[i - val];
}
}
int n;
int a[N];
int cnt[A];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < n; i++) {
add(a[i]);
}
if (sum & 1 || !check(sum / 2)) {
cout << 0;
return 0;
}
for (int i = 0; i < n; i++) {
if (i) add(a[i - 1]);
del(a[i]);
for (int s = 0; s < A; s++) {
if (check(s)) {
cnt[abs(2 * s - sum)]++;
}
}
}
vector<int> res;
for (int i = 0; i < A; i++) {
if (cnt[i] == 2 * n)
res.push_back(i);
}
cout << (int)res.size() << '\n';
for (int c : res) cout << c << ' ';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
3160 KB |
Output is correct |
2 |
Correct |
12 ms |
3392 KB |
Output is correct |
3 |
Correct |
3 ms |
3164 KB |
Output is correct |
4 |
Correct |
8 ms |
3164 KB |
Output is correct |
5 |
Correct |
27 ms |
3400 KB |
Output is correct |
6 |
Correct |
15 ms |
3164 KB |
Output is correct |
7 |
Correct |
12 ms |
3164 KB |
Output is correct |
8 |
Correct |
21 ms |
3164 KB |
Output is correct |
9 |
Correct |
19 ms |
3160 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
3160 KB |
Output is correct |
2 |
Correct |
12 ms |
3392 KB |
Output is correct |
3 |
Correct |
3 ms |
3164 KB |
Output is correct |
4 |
Correct |
8 ms |
3164 KB |
Output is correct |
5 |
Correct |
27 ms |
3400 KB |
Output is correct |
6 |
Correct |
15 ms |
3164 KB |
Output is correct |
7 |
Correct |
12 ms |
3164 KB |
Output is correct |
8 |
Correct |
21 ms |
3164 KB |
Output is correct |
9 |
Correct |
19 ms |
3160 KB |
Output is correct |
10 |
Correct |
51 ms |
3160 KB |
Output is correct |
11 |
Correct |
52 ms |
3164 KB |
Output is correct |
12 |
Correct |
60 ms |
3160 KB |
Output is correct |
13 |
Correct |
49 ms |
3164 KB |
Output is correct |
14 |
Correct |
49 ms |
3160 KB |
Output is correct |
15 |
Correct |
49 ms |
3164 KB |
Output is correct |
16 |
Correct |
53 ms |
3160 KB |
Output is correct |
17 |
Correct |
35 ms |
3164 KB |
Output is correct |
18 |
Correct |
44 ms |
3164 KB |
Output is correct |
19 |
Correct |
47 ms |
3164 KB |
Output is correct |
20 |
Correct |
52 ms |
3164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
3160 KB |
Output is correct |
2 |
Correct |
12 ms |
3392 KB |
Output is correct |
3 |
Correct |
3 ms |
3164 KB |
Output is correct |
4 |
Correct |
8 ms |
3164 KB |
Output is correct |
5 |
Correct |
27 ms |
3400 KB |
Output is correct |
6 |
Correct |
15 ms |
3164 KB |
Output is correct |
7 |
Correct |
12 ms |
3164 KB |
Output is correct |
8 |
Correct |
21 ms |
3164 KB |
Output is correct |
9 |
Correct |
19 ms |
3160 KB |
Output is correct |
10 |
Correct |
51 ms |
3160 KB |
Output is correct |
11 |
Correct |
52 ms |
3164 KB |
Output is correct |
12 |
Correct |
60 ms |
3160 KB |
Output is correct |
13 |
Correct |
49 ms |
3164 KB |
Output is correct |
14 |
Correct |
49 ms |
3160 KB |
Output is correct |
15 |
Correct |
49 ms |
3164 KB |
Output is correct |
16 |
Correct |
53 ms |
3160 KB |
Output is correct |
17 |
Correct |
35 ms |
3164 KB |
Output is correct |
18 |
Correct |
44 ms |
3164 KB |
Output is correct |
19 |
Correct |
47 ms |
3164 KB |
Output is correct |
20 |
Correct |
52 ms |
3164 KB |
Output is correct |
21 |
Correct |
112 ms |
3164 KB |
Output is correct |
22 |
Correct |
130 ms |
3384 KB |
Output is correct |
23 |
Correct |
85 ms |
3396 KB |
Output is correct |
24 |
Correct |
166 ms |
3408 KB |
Output is correct |
25 |
Correct |
163 ms |
3388 KB |
Output is correct |
26 |
Correct |
191 ms |
3384 KB |
Output is correct |
27 |
Correct |
170 ms |
3372 KB |
Output is correct |
28 |
Correct |
177 ms |
3372 KB |
Output is correct |
29 |
Correct |
175 ms |
3408 KB |
Output is correct |
30 |
Correct |
184 ms |
3164 KB |
Output is correct |
31 |
Correct |
176 ms |
3412 KB |
Output is correct |
32 |
Correct |
181 ms |
3408 KB |
Output is correct |
33 |
Correct |
175 ms |
3416 KB |
Output is correct |
34 |
Correct |
166 ms |
3408 KB |
Output is correct |
35 |
Correct |
173 ms |
3376 KB |
Output is correct |
36 |
Correct |
185 ms |
3372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
3160 KB |
Output is correct |
2 |
Correct |
12 ms |
3392 KB |
Output is correct |
3 |
Correct |
3 ms |
3164 KB |
Output is correct |
4 |
Correct |
8 ms |
3164 KB |
Output is correct |
5 |
Correct |
27 ms |
3400 KB |
Output is correct |
6 |
Correct |
15 ms |
3164 KB |
Output is correct |
7 |
Correct |
12 ms |
3164 KB |
Output is correct |
8 |
Correct |
21 ms |
3164 KB |
Output is correct |
9 |
Correct |
19 ms |
3160 KB |
Output is correct |
10 |
Correct |
51 ms |
3160 KB |
Output is correct |
11 |
Correct |
52 ms |
3164 KB |
Output is correct |
12 |
Correct |
60 ms |
3160 KB |
Output is correct |
13 |
Correct |
49 ms |
3164 KB |
Output is correct |
14 |
Correct |
49 ms |
3160 KB |
Output is correct |
15 |
Correct |
49 ms |
3164 KB |
Output is correct |
16 |
Correct |
53 ms |
3160 KB |
Output is correct |
17 |
Correct |
35 ms |
3164 KB |
Output is correct |
18 |
Correct |
44 ms |
3164 KB |
Output is correct |
19 |
Correct |
47 ms |
3164 KB |
Output is correct |
20 |
Correct |
52 ms |
3164 KB |
Output is correct |
21 |
Correct |
112 ms |
3164 KB |
Output is correct |
22 |
Correct |
130 ms |
3384 KB |
Output is correct |
23 |
Correct |
85 ms |
3396 KB |
Output is correct |
24 |
Correct |
166 ms |
3408 KB |
Output is correct |
25 |
Correct |
163 ms |
3388 KB |
Output is correct |
26 |
Correct |
191 ms |
3384 KB |
Output is correct |
27 |
Correct |
170 ms |
3372 KB |
Output is correct |
28 |
Correct |
177 ms |
3372 KB |
Output is correct |
29 |
Correct |
175 ms |
3408 KB |
Output is correct |
30 |
Correct |
184 ms |
3164 KB |
Output is correct |
31 |
Correct |
176 ms |
3412 KB |
Output is correct |
32 |
Correct |
181 ms |
3408 KB |
Output is correct |
33 |
Correct |
175 ms |
3416 KB |
Output is correct |
34 |
Correct |
166 ms |
3408 KB |
Output is correct |
35 |
Correct |
173 ms |
3376 KB |
Output is correct |
36 |
Correct |
185 ms |
3372 KB |
Output is correct |
37 |
Correct |
393 ms |
3408 KB |
Output is correct |
38 |
Correct |
401 ms |
3408 KB |
Output is correct |
39 |
Correct |
411 ms |
3412 KB |
Output is correct |
40 |
Correct |
600 ms |
3632 KB |
Output is correct |
41 |
Correct |
461 ms |
3664 KB |
Output is correct |
42 |
Correct |
562 ms |
3668 KB |
Output is correct |
43 |
Correct |
610 ms |
3924 KB |
Output is correct |
44 |
Correct |
638 ms |
3924 KB |
Output is correct |
45 |
Correct |
640 ms |
3848 KB |
Output is correct |
46 |
Correct |
569 ms |
3416 KB |
Output is correct |
47 |
Correct |
560 ms |
3664 KB |
Output is correct |
48 |
Correct |
619 ms |
3924 KB |
Output is correct |
49 |
Correct |
550 ms |
3628 KB |
Output is correct |
50 |
Correct |
551 ms |
3672 KB |
Output is correct |
51 |
Correct |
169 ms |
3160 KB |
Output is correct |
52 |
Correct |
731 ms |
3884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
3160 KB |
Output is correct |
2 |
Correct |
12 ms |
3392 KB |
Output is correct |
3 |
Correct |
3 ms |
3164 KB |
Output is correct |
4 |
Correct |
8 ms |
3164 KB |
Output is correct |
5 |
Correct |
27 ms |
3400 KB |
Output is correct |
6 |
Correct |
15 ms |
3164 KB |
Output is correct |
7 |
Correct |
12 ms |
3164 KB |
Output is correct |
8 |
Correct |
21 ms |
3164 KB |
Output is correct |
9 |
Correct |
19 ms |
3160 KB |
Output is correct |
10 |
Correct |
51 ms |
3160 KB |
Output is correct |
11 |
Correct |
52 ms |
3164 KB |
Output is correct |
12 |
Correct |
60 ms |
3160 KB |
Output is correct |
13 |
Correct |
49 ms |
3164 KB |
Output is correct |
14 |
Correct |
49 ms |
3160 KB |
Output is correct |
15 |
Correct |
49 ms |
3164 KB |
Output is correct |
16 |
Correct |
53 ms |
3160 KB |
Output is correct |
17 |
Correct |
35 ms |
3164 KB |
Output is correct |
18 |
Correct |
44 ms |
3164 KB |
Output is correct |
19 |
Correct |
47 ms |
3164 KB |
Output is correct |
20 |
Correct |
52 ms |
3164 KB |
Output is correct |
21 |
Correct |
112 ms |
3164 KB |
Output is correct |
22 |
Correct |
130 ms |
3384 KB |
Output is correct |
23 |
Correct |
85 ms |
3396 KB |
Output is correct |
24 |
Correct |
166 ms |
3408 KB |
Output is correct |
25 |
Correct |
163 ms |
3388 KB |
Output is correct |
26 |
Correct |
191 ms |
3384 KB |
Output is correct |
27 |
Correct |
170 ms |
3372 KB |
Output is correct |
28 |
Correct |
177 ms |
3372 KB |
Output is correct |
29 |
Correct |
175 ms |
3408 KB |
Output is correct |
30 |
Correct |
184 ms |
3164 KB |
Output is correct |
31 |
Correct |
176 ms |
3412 KB |
Output is correct |
32 |
Correct |
181 ms |
3408 KB |
Output is correct |
33 |
Correct |
175 ms |
3416 KB |
Output is correct |
34 |
Correct |
166 ms |
3408 KB |
Output is correct |
35 |
Correct |
173 ms |
3376 KB |
Output is correct |
36 |
Correct |
185 ms |
3372 KB |
Output is correct |
37 |
Correct |
393 ms |
3408 KB |
Output is correct |
38 |
Correct |
401 ms |
3408 KB |
Output is correct |
39 |
Correct |
411 ms |
3412 KB |
Output is correct |
40 |
Correct |
600 ms |
3632 KB |
Output is correct |
41 |
Correct |
461 ms |
3664 KB |
Output is correct |
42 |
Correct |
562 ms |
3668 KB |
Output is correct |
43 |
Correct |
610 ms |
3924 KB |
Output is correct |
44 |
Correct |
638 ms |
3924 KB |
Output is correct |
45 |
Correct |
640 ms |
3848 KB |
Output is correct |
46 |
Correct |
569 ms |
3416 KB |
Output is correct |
47 |
Correct |
560 ms |
3664 KB |
Output is correct |
48 |
Correct |
619 ms |
3924 KB |
Output is correct |
49 |
Correct |
550 ms |
3628 KB |
Output is correct |
50 |
Correct |
551 ms |
3672 KB |
Output is correct |
51 |
Correct |
169 ms |
3160 KB |
Output is correct |
52 |
Correct |
731 ms |
3884 KB |
Output is correct |
53 |
Correct |
778 ms |
3664 KB |
Output is correct |
54 |
Correct |
961 ms |
3892 KB |
Output is correct |
55 |
Execution timed out |
1062 ms |
3648 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
3160 KB |
Output is correct |
2 |
Correct |
12 ms |
3392 KB |
Output is correct |
3 |
Correct |
3 ms |
3164 KB |
Output is correct |
4 |
Correct |
8 ms |
3164 KB |
Output is correct |
5 |
Correct |
27 ms |
3400 KB |
Output is correct |
6 |
Correct |
15 ms |
3164 KB |
Output is correct |
7 |
Correct |
12 ms |
3164 KB |
Output is correct |
8 |
Correct |
21 ms |
3164 KB |
Output is correct |
9 |
Correct |
19 ms |
3160 KB |
Output is correct |
10 |
Correct |
51 ms |
3160 KB |
Output is correct |
11 |
Correct |
52 ms |
3164 KB |
Output is correct |
12 |
Correct |
60 ms |
3160 KB |
Output is correct |
13 |
Correct |
49 ms |
3164 KB |
Output is correct |
14 |
Correct |
49 ms |
3160 KB |
Output is correct |
15 |
Correct |
49 ms |
3164 KB |
Output is correct |
16 |
Correct |
53 ms |
3160 KB |
Output is correct |
17 |
Correct |
35 ms |
3164 KB |
Output is correct |
18 |
Correct |
44 ms |
3164 KB |
Output is correct |
19 |
Correct |
47 ms |
3164 KB |
Output is correct |
20 |
Correct |
52 ms |
3164 KB |
Output is correct |
21 |
Correct |
112 ms |
3164 KB |
Output is correct |
22 |
Correct |
130 ms |
3384 KB |
Output is correct |
23 |
Correct |
85 ms |
3396 KB |
Output is correct |
24 |
Correct |
166 ms |
3408 KB |
Output is correct |
25 |
Correct |
163 ms |
3388 KB |
Output is correct |
26 |
Correct |
191 ms |
3384 KB |
Output is correct |
27 |
Correct |
170 ms |
3372 KB |
Output is correct |
28 |
Correct |
177 ms |
3372 KB |
Output is correct |
29 |
Correct |
175 ms |
3408 KB |
Output is correct |
30 |
Correct |
184 ms |
3164 KB |
Output is correct |
31 |
Correct |
176 ms |
3412 KB |
Output is correct |
32 |
Correct |
181 ms |
3408 KB |
Output is correct |
33 |
Correct |
175 ms |
3416 KB |
Output is correct |
34 |
Correct |
166 ms |
3408 KB |
Output is correct |
35 |
Correct |
173 ms |
3376 KB |
Output is correct |
36 |
Correct |
185 ms |
3372 KB |
Output is correct |
37 |
Correct |
393 ms |
3408 KB |
Output is correct |
38 |
Correct |
401 ms |
3408 KB |
Output is correct |
39 |
Correct |
411 ms |
3412 KB |
Output is correct |
40 |
Correct |
600 ms |
3632 KB |
Output is correct |
41 |
Correct |
461 ms |
3664 KB |
Output is correct |
42 |
Correct |
562 ms |
3668 KB |
Output is correct |
43 |
Correct |
610 ms |
3924 KB |
Output is correct |
44 |
Correct |
638 ms |
3924 KB |
Output is correct |
45 |
Correct |
640 ms |
3848 KB |
Output is correct |
46 |
Correct |
569 ms |
3416 KB |
Output is correct |
47 |
Correct |
560 ms |
3664 KB |
Output is correct |
48 |
Correct |
619 ms |
3924 KB |
Output is correct |
49 |
Correct |
550 ms |
3628 KB |
Output is correct |
50 |
Correct |
551 ms |
3672 KB |
Output is correct |
51 |
Correct |
169 ms |
3160 KB |
Output is correct |
52 |
Correct |
731 ms |
3884 KB |
Output is correct |
53 |
Correct |
778 ms |
3664 KB |
Output is correct |
54 |
Correct |
961 ms |
3892 KB |
Output is correct |
55 |
Execution timed out |
1062 ms |
3648 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |