#include <bits/stdc++.h>
using namespace std;
const int MOD1 = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int MOD3 = 998244353;
const int MOD4 = 999990011;
template<unsigned int MOD>
struct mint {
int v;
mint() {}
mint(long long val) : v(val % 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 = 370;
const int A = 123000;
mint<MOD1> dp1[A]{1};
mint<MOD2> dp2[A]{1};
mint<MOD2> dp3[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];
}
}
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);
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];
}
}
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 << ' ';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1880 KB |
Output is correct |
2 |
Correct |
11 ms |
1884 KB |
Output is correct |
3 |
Correct |
3 ms |
1884 KB |
Output is correct |
4 |
Correct |
8 ms |
1880 KB |
Output is correct |
5 |
Correct |
23 ms |
1884 KB |
Output is correct |
6 |
Correct |
15 ms |
1884 KB |
Output is correct |
7 |
Correct |
11 ms |
1884 KB |
Output is correct |
8 |
Correct |
23 ms |
1884 KB |
Output is correct |
9 |
Correct |
21 ms |
1880 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1880 KB |
Output is correct |
2 |
Correct |
11 ms |
1884 KB |
Output is correct |
3 |
Correct |
3 ms |
1884 KB |
Output is correct |
4 |
Correct |
8 ms |
1880 KB |
Output is correct |
5 |
Correct |
23 ms |
1884 KB |
Output is correct |
6 |
Correct |
15 ms |
1884 KB |
Output is correct |
7 |
Correct |
11 ms |
1884 KB |
Output is correct |
8 |
Correct |
23 ms |
1884 KB |
Output is correct |
9 |
Correct |
21 ms |
1880 KB |
Output is correct |
10 |
Correct |
54 ms |
1880 KB |
Output is correct |
11 |
Correct |
54 ms |
1884 KB |
Output is correct |
12 |
Correct |
54 ms |
1884 KB |
Output is correct |
13 |
Correct |
50 ms |
1884 KB |
Output is correct |
14 |
Correct |
55 ms |
1884 KB |
Output is correct |
15 |
Correct |
53 ms |
1884 KB |
Output is correct |
16 |
Correct |
55 ms |
1880 KB |
Output is correct |
17 |
Correct |
42 ms |
1884 KB |
Output is correct |
18 |
Correct |
46 ms |
1884 KB |
Output is correct |
19 |
Correct |
48 ms |
1884 KB |
Output is correct |
20 |
Correct |
55 ms |
1884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1880 KB |
Output is correct |
2 |
Correct |
11 ms |
1884 KB |
Output is correct |
3 |
Correct |
3 ms |
1884 KB |
Output is correct |
4 |
Correct |
8 ms |
1880 KB |
Output is correct |
5 |
Correct |
23 ms |
1884 KB |
Output is correct |
6 |
Correct |
15 ms |
1884 KB |
Output is correct |
7 |
Correct |
11 ms |
1884 KB |
Output is correct |
8 |
Correct |
23 ms |
1884 KB |
Output is correct |
9 |
Correct |
21 ms |
1880 KB |
Output is correct |
10 |
Correct |
54 ms |
1880 KB |
Output is correct |
11 |
Correct |
54 ms |
1884 KB |
Output is correct |
12 |
Correct |
54 ms |
1884 KB |
Output is correct |
13 |
Correct |
50 ms |
1884 KB |
Output is correct |
14 |
Correct |
55 ms |
1884 KB |
Output is correct |
15 |
Correct |
53 ms |
1884 KB |
Output is correct |
16 |
Correct |
55 ms |
1880 KB |
Output is correct |
17 |
Correct |
42 ms |
1884 KB |
Output is correct |
18 |
Correct |
46 ms |
1884 KB |
Output is correct |
19 |
Correct |
48 ms |
1884 KB |
Output is correct |
20 |
Correct |
55 ms |
1884 KB |
Output is correct |
21 |
Correct |
115 ms |
1904 KB |
Output is correct |
22 |
Correct |
136 ms |
1884 KB |
Output is correct |
23 |
Correct |
91 ms |
1880 KB |
Output is correct |
24 |
Correct |
169 ms |
1884 KB |
Output is correct |
25 |
Correct |
174 ms |
1916 KB |
Output is correct |
26 |
Correct |
185 ms |
1920 KB |
Output is correct |
27 |
Correct |
175 ms |
1916 KB |
Output is correct |
28 |
Correct |
179 ms |
1920 KB |
Output is correct |
29 |
Correct |
184 ms |
1880 KB |
Output is correct |
30 |
Correct |
178 ms |
1896 KB |
Output is correct |
31 |
Correct |
186 ms |
1884 KB |
Output is correct |
32 |
Correct |
203 ms |
2136 KB |
Output is correct |
33 |
Correct |
182 ms |
1884 KB |
Output is correct |
34 |
Correct |
183 ms |
1880 KB |
Output is correct |
35 |
Correct |
185 ms |
1880 KB |
Output is correct |
36 |
Correct |
185 ms |
1892 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1880 KB |
Output is correct |
2 |
Correct |
11 ms |
1884 KB |
Output is correct |
3 |
Correct |
3 ms |
1884 KB |
Output is correct |
4 |
Correct |
8 ms |
1880 KB |
Output is correct |
5 |
Correct |
23 ms |
1884 KB |
Output is correct |
6 |
Correct |
15 ms |
1884 KB |
Output is correct |
7 |
Correct |
11 ms |
1884 KB |
Output is correct |
8 |
Correct |
23 ms |
1884 KB |
Output is correct |
9 |
Correct |
21 ms |
1880 KB |
Output is correct |
10 |
Correct |
54 ms |
1880 KB |
Output is correct |
11 |
Correct |
54 ms |
1884 KB |
Output is correct |
12 |
Correct |
54 ms |
1884 KB |
Output is correct |
13 |
Correct |
50 ms |
1884 KB |
Output is correct |
14 |
Correct |
55 ms |
1884 KB |
Output is correct |
15 |
Correct |
53 ms |
1884 KB |
Output is correct |
16 |
Correct |
55 ms |
1880 KB |
Output is correct |
17 |
Correct |
42 ms |
1884 KB |
Output is correct |
18 |
Correct |
46 ms |
1884 KB |
Output is correct |
19 |
Correct |
48 ms |
1884 KB |
Output is correct |
20 |
Correct |
55 ms |
1884 KB |
Output is correct |
21 |
Correct |
115 ms |
1904 KB |
Output is correct |
22 |
Correct |
136 ms |
1884 KB |
Output is correct |
23 |
Correct |
91 ms |
1880 KB |
Output is correct |
24 |
Correct |
169 ms |
1884 KB |
Output is correct |
25 |
Correct |
174 ms |
1916 KB |
Output is correct |
26 |
Correct |
185 ms |
1920 KB |
Output is correct |
27 |
Correct |
175 ms |
1916 KB |
Output is correct |
28 |
Correct |
179 ms |
1920 KB |
Output is correct |
29 |
Correct |
184 ms |
1880 KB |
Output is correct |
30 |
Correct |
178 ms |
1896 KB |
Output is correct |
31 |
Correct |
186 ms |
1884 KB |
Output is correct |
32 |
Correct |
203 ms |
2136 KB |
Output is correct |
33 |
Correct |
182 ms |
1884 KB |
Output is correct |
34 |
Correct |
183 ms |
1880 KB |
Output is correct |
35 |
Correct |
185 ms |
1880 KB |
Output is correct |
36 |
Correct |
185 ms |
1892 KB |
Output is correct |
37 |
Correct |
372 ms |
1896 KB |
Output is correct |
38 |
Correct |
371 ms |
1888 KB |
Output is correct |
39 |
Correct |
443 ms |
2128 KB |
Output is correct |
40 |
Correct |
485 ms |
2132 KB |
Output is correct |
41 |
Correct |
480 ms |
2388 KB |
Output is correct |
42 |
Correct |
447 ms |
2136 KB |
Output is correct |
43 |
Correct |
452 ms |
2392 KB |
Output is correct |
44 |
Correct |
484 ms |
2384 KB |
Output is correct |
45 |
Correct |
462 ms |
2388 KB |
Output is correct |
46 |
Correct |
504 ms |
1884 KB |
Output is correct |
47 |
Correct |
457 ms |
2012 KB |
Output is correct |
48 |
Correct |
458 ms |
2384 KB |
Output is correct |
49 |
Correct |
490 ms |
2124 KB |
Output is correct |
50 |
Correct |
454 ms |
2156 KB |
Output is correct |
51 |
Correct |
158 ms |
2132 KB |
Output is correct |
52 |
Correct |
518 ms |
2388 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1880 KB |
Output is correct |
2 |
Correct |
11 ms |
1884 KB |
Output is correct |
3 |
Correct |
3 ms |
1884 KB |
Output is correct |
4 |
Correct |
8 ms |
1880 KB |
Output is correct |
5 |
Correct |
23 ms |
1884 KB |
Output is correct |
6 |
Correct |
15 ms |
1884 KB |
Output is correct |
7 |
Correct |
11 ms |
1884 KB |
Output is correct |
8 |
Correct |
23 ms |
1884 KB |
Output is correct |
9 |
Correct |
21 ms |
1880 KB |
Output is correct |
10 |
Correct |
54 ms |
1880 KB |
Output is correct |
11 |
Correct |
54 ms |
1884 KB |
Output is correct |
12 |
Correct |
54 ms |
1884 KB |
Output is correct |
13 |
Correct |
50 ms |
1884 KB |
Output is correct |
14 |
Correct |
55 ms |
1884 KB |
Output is correct |
15 |
Correct |
53 ms |
1884 KB |
Output is correct |
16 |
Correct |
55 ms |
1880 KB |
Output is correct |
17 |
Correct |
42 ms |
1884 KB |
Output is correct |
18 |
Correct |
46 ms |
1884 KB |
Output is correct |
19 |
Correct |
48 ms |
1884 KB |
Output is correct |
20 |
Correct |
55 ms |
1884 KB |
Output is correct |
21 |
Correct |
115 ms |
1904 KB |
Output is correct |
22 |
Correct |
136 ms |
1884 KB |
Output is correct |
23 |
Correct |
91 ms |
1880 KB |
Output is correct |
24 |
Correct |
169 ms |
1884 KB |
Output is correct |
25 |
Correct |
174 ms |
1916 KB |
Output is correct |
26 |
Correct |
185 ms |
1920 KB |
Output is correct |
27 |
Correct |
175 ms |
1916 KB |
Output is correct |
28 |
Correct |
179 ms |
1920 KB |
Output is correct |
29 |
Correct |
184 ms |
1880 KB |
Output is correct |
30 |
Correct |
178 ms |
1896 KB |
Output is correct |
31 |
Correct |
186 ms |
1884 KB |
Output is correct |
32 |
Correct |
203 ms |
2136 KB |
Output is correct |
33 |
Correct |
182 ms |
1884 KB |
Output is correct |
34 |
Correct |
183 ms |
1880 KB |
Output is correct |
35 |
Correct |
185 ms |
1880 KB |
Output is correct |
36 |
Correct |
185 ms |
1892 KB |
Output is correct |
37 |
Correct |
372 ms |
1896 KB |
Output is correct |
38 |
Correct |
371 ms |
1888 KB |
Output is correct |
39 |
Correct |
443 ms |
2128 KB |
Output is correct |
40 |
Correct |
485 ms |
2132 KB |
Output is correct |
41 |
Correct |
480 ms |
2388 KB |
Output is correct |
42 |
Correct |
447 ms |
2136 KB |
Output is correct |
43 |
Correct |
452 ms |
2392 KB |
Output is correct |
44 |
Correct |
484 ms |
2384 KB |
Output is correct |
45 |
Correct |
462 ms |
2388 KB |
Output is correct |
46 |
Correct |
504 ms |
1884 KB |
Output is correct |
47 |
Correct |
457 ms |
2012 KB |
Output is correct |
48 |
Correct |
458 ms |
2384 KB |
Output is correct |
49 |
Correct |
490 ms |
2124 KB |
Output is correct |
50 |
Correct |
454 ms |
2156 KB |
Output is correct |
51 |
Correct |
158 ms |
2132 KB |
Output is correct |
52 |
Correct |
518 ms |
2388 KB |
Output is correct |
53 |
Correct |
549 ms |
2312 KB |
Output is correct |
54 |
Correct |
653 ms |
2356 KB |
Output is correct |
55 |
Correct |
703 ms |
2776 KB |
Output is correct |
56 |
Correct |
555 ms |
2392 KB |
Output is correct |
57 |
Correct |
660 ms |
2784 KB |
Output is correct |
58 |
Correct |
666 ms |
2380 KB |
Output is correct |
59 |
Incorrect |
680 ms |
2572 KB |
Output isn't correct |
60 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1880 KB |
Output is correct |
2 |
Correct |
11 ms |
1884 KB |
Output is correct |
3 |
Correct |
3 ms |
1884 KB |
Output is correct |
4 |
Correct |
8 ms |
1880 KB |
Output is correct |
5 |
Correct |
23 ms |
1884 KB |
Output is correct |
6 |
Correct |
15 ms |
1884 KB |
Output is correct |
7 |
Correct |
11 ms |
1884 KB |
Output is correct |
8 |
Correct |
23 ms |
1884 KB |
Output is correct |
9 |
Correct |
21 ms |
1880 KB |
Output is correct |
10 |
Correct |
54 ms |
1880 KB |
Output is correct |
11 |
Correct |
54 ms |
1884 KB |
Output is correct |
12 |
Correct |
54 ms |
1884 KB |
Output is correct |
13 |
Correct |
50 ms |
1884 KB |
Output is correct |
14 |
Correct |
55 ms |
1884 KB |
Output is correct |
15 |
Correct |
53 ms |
1884 KB |
Output is correct |
16 |
Correct |
55 ms |
1880 KB |
Output is correct |
17 |
Correct |
42 ms |
1884 KB |
Output is correct |
18 |
Correct |
46 ms |
1884 KB |
Output is correct |
19 |
Correct |
48 ms |
1884 KB |
Output is correct |
20 |
Correct |
55 ms |
1884 KB |
Output is correct |
21 |
Correct |
115 ms |
1904 KB |
Output is correct |
22 |
Correct |
136 ms |
1884 KB |
Output is correct |
23 |
Correct |
91 ms |
1880 KB |
Output is correct |
24 |
Correct |
169 ms |
1884 KB |
Output is correct |
25 |
Correct |
174 ms |
1916 KB |
Output is correct |
26 |
Correct |
185 ms |
1920 KB |
Output is correct |
27 |
Correct |
175 ms |
1916 KB |
Output is correct |
28 |
Correct |
179 ms |
1920 KB |
Output is correct |
29 |
Correct |
184 ms |
1880 KB |
Output is correct |
30 |
Correct |
178 ms |
1896 KB |
Output is correct |
31 |
Correct |
186 ms |
1884 KB |
Output is correct |
32 |
Correct |
203 ms |
2136 KB |
Output is correct |
33 |
Correct |
182 ms |
1884 KB |
Output is correct |
34 |
Correct |
183 ms |
1880 KB |
Output is correct |
35 |
Correct |
185 ms |
1880 KB |
Output is correct |
36 |
Correct |
185 ms |
1892 KB |
Output is correct |
37 |
Correct |
372 ms |
1896 KB |
Output is correct |
38 |
Correct |
371 ms |
1888 KB |
Output is correct |
39 |
Correct |
443 ms |
2128 KB |
Output is correct |
40 |
Correct |
485 ms |
2132 KB |
Output is correct |
41 |
Correct |
480 ms |
2388 KB |
Output is correct |
42 |
Correct |
447 ms |
2136 KB |
Output is correct |
43 |
Correct |
452 ms |
2392 KB |
Output is correct |
44 |
Correct |
484 ms |
2384 KB |
Output is correct |
45 |
Correct |
462 ms |
2388 KB |
Output is correct |
46 |
Correct |
504 ms |
1884 KB |
Output is correct |
47 |
Correct |
457 ms |
2012 KB |
Output is correct |
48 |
Correct |
458 ms |
2384 KB |
Output is correct |
49 |
Correct |
490 ms |
2124 KB |
Output is correct |
50 |
Correct |
454 ms |
2156 KB |
Output is correct |
51 |
Correct |
158 ms |
2132 KB |
Output is correct |
52 |
Correct |
518 ms |
2388 KB |
Output is correct |
53 |
Correct |
549 ms |
2312 KB |
Output is correct |
54 |
Correct |
653 ms |
2356 KB |
Output is correct |
55 |
Correct |
703 ms |
2776 KB |
Output is correct |
56 |
Correct |
555 ms |
2392 KB |
Output is correct |
57 |
Correct |
660 ms |
2784 KB |
Output is correct |
58 |
Correct |
666 ms |
2380 KB |
Output is correct |
59 |
Incorrect |
680 ms |
2572 KB |
Output isn't correct |
60 |
Halted |
0 ms |
0 KB |
- |