#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pi> vp;
typedef vector<pl> vpl;
void no(){
cout << "0\n";
exit(0);
}
const int M = 250000;
int d[M+505], dp[M+505];
vi cnt(M+4);
int main()
{
int n;
cin >> n;
vi a(n);
int suma = 0;
bool pp = 0, np = 0;
for (auto& i : a){
cin >> i;
suma += i;
if (i%2)
np=1;
else
pp=1;
}
if ((pp && np) || suma%2) no();
dp[0]=1;
for (int i = 0; i < n; ++i){
for (int j = M; j > -1; --j){
dp[a[i]+j] += dp[j];
}
}
if (!dp[suma/2]) no();
vi sol;
for (int i = 0; i < n; ++i){
memset(d, 0, sizeof(d));
for (int j = 0; j <= M; ++j){
d[j] += dp[j];
d[j+a[i]] -= d[j];
}
for (int j = 0; j <= M; ++j){
if ((suma-a[i]+j)%2 == 0 && suma-a[i]-j>=0 && d[(suma-a[i]-j)/2]){
++cnt[j];
}
}
}
for (int i = 1; i <= M; ++i)
if (cnt[i] == n)
sol.push_back(i);
cout << (int)sol.size() << '\n';
for (auto& i : sol)
cout << i << ' ';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
3308 KB |
Output is correct |
2 |
Correct |
16 ms |
3308 KB |
Output is correct |
3 |
Correct |
5 ms |
2284 KB |
Output is correct |
4 |
Correct |
11 ms |
3308 KB |
Output is correct |
5 |
Correct |
28 ms |
3308 KB |
Output is correct |
6 |
Correct |
20 ms |
3308 KB |
Output is correct |
7 |
Correct |
15 ms |
3308 KB |
Output is correct |
8 |
Correct |
28 ms |
3308 KB |
Output is correct |
9 |
Correct |
1 ms |
1260 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
3308 KB |
Output is correct |
2 |
Correct |
16 ms |
3308 KB |
Output is correct |
3 |
Correct |
5 ms |
2284 KB |
Output is correct |
4 |
Correct |
11 ms |
3308 KB |
Output is correct |
5 |
Correct |
28 ms |
3308 KB |
Output is correct |
6 |
Correct |
20 ms |
3308 KB |
Output is correct |
7 |
Correct |
15 ms |
3308 KB |
Output is correct |
8 |
Correct |
28 ms |
3308 KB |
Output is correct |
9 |
Correct |
1 ms |
1260 KB |
Output is correct |
10 |
Correct |
65 ms |
3308 KB |
Output is correct |
11 |
Correct |
65 ms |
3308 KB |
Output is correct |
12 |
Correct |
67 ms |
3436 KB |
Output is correct |
13 |
Correct |
1 ms |
1260 KB |
Output is correct |
14 |
Correct |
64 ms |
3312 KB |
Output is correct |
15 |
Correct |
61 ms |
3232 KB |
Output is correct |
16 |
Correct |
66 ms |
3308 KB |
Output is correct |
17 |
Correct |
41 ms |
3308 KB |
Output is correct |
18 |
Correct |
56 ms |
3308 KB |
Output is correct |
19 |
Correct |
57 ms |
3232 KB |
Output is correct |
20 |
Correct |
65 ms |
3308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
3308 KB |
Output is correct |
2 |
Correct |
16 ms |
3308 KB |
Output is correct |
3 |
Correct |
5 ms |
2284 KB |
Output is correct |
4 |
Correct |
11 ms |
3308 KB |
Output is correct |
5 |
Correct |
28 ms |
3308 KB |
Output is correct |
6 |
Correct |
20 ms |
3308 KB |
Output is correct |
7 |
Correct |
15 ms |
3308 KB |
Output is correct |
8 |
Correct |
28 ms |
3308 KB |
Output is correct |
9 |
Correct |
1 ms |
1260 KB |
Output is correct |
10 |
Correct |
65 ms |
3308 KB |
Output is correct |
11 |
Correct |
65 ms |
3308 KB |
Output is correct |
12 |
Correct |
67 ms |
3436 KB |
Output is correct |
13 |
Correct |
1 ms |
1260 KB |
Output is correct |
14 |
Correct |
64 ms |
3312 KB |
Output is correct |
15 |
Correct |
61 ms |
3232 KB |
Output is correct |
16 |
Correct |
66 ms |
3308 KB |
Output is correct |
17 |
Correct |
41 ms |
3308 KB |
Output is correct |
18 |
Correct |
56 ms |
3308 KB |
Output is correct |
19 |
Correct |
57 ms |
3232 KB |
Output is correct |
20 |
Correct |
65 ms |
3308 KB |
Output is correct |
21 |
Correct |
135 ms |
3308 KB |
Output is correct |
22 |
Correct |
160 ms |
3308 KB |
Output is correct |
23 |
Correct |
108 ms |
3436 KB |
Output is correct |
24 |
Correct |
199 ms |
3436 KB |
Output is correct |
25 |
Correct |
201 ms |
3308 KB |
Output is correct |
26 |
Correct |
213 ms |
3436 KB |
Output is correct |
27 |
Correct |
214 ms |
3308 KB |
Output is correct |
28 |
Correct |
214 ms |
3308 KB |
Output is correct |
29 |
Correct |
213 ms |
3436 KB |
Output is correct |
30 |
Correct |
1 ms |
1260 KB |
Output is correct |
31 |
Correct |
211 ms |
3308 KB |
Output is correct |
32 |
Correct |
212 ms |
3436 KB |
Output is correct |
33 |
Correct |
212 ms |
3436 KB |
Output is correct |
34 |
Correct |
211 ms |
3308 KB |
Output is correct |
35 |
Correct |
202 ms |
3308 KB |
Output is correct |
36 |
Correct |
219 ms |
3308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
3308 KB |
Output is correct |
2 |
Correct |
16 ms |
3308 KB |
Output is correct |
3 |
Correct |
5 ms |
2284 KB |
Output is correct |
4 |
Correct |
11 ms |
3308 KB |
Output is correct |
5 |
Correct |
28 ms |
3308 KB |
Output is correct |
6 |
Correct |
20 ms |
3308 KB |
Output is correct |
7 |
Correct |
15 ms |
3308 KB |
Output is correct |
8 |
Correct |
28 ms |
3308 KB |
Output is correct |
9 |
Correct |
1 ms |
1260 KB |
Output is correct |
10 |
Correct |
65 ms |
3308 KB |
Output is correct |
11 |
Correct |
65 ms |
3308 KB |
Output is correct |
12 |
Correct |
67 ms |
3436 KB |
Output is correct |
13 |
Correct |
1 ms |
1260 KB |
Output is correct |
14 |
Correct |
64 ms |
3312 KB |
Output is correct |
15 |
Correct |
61 ms |
3232 KB |
Output is correct |
16 |
Correct |
66 ms |
3308 KB |
Output is correct |
17 |
Correct |
41 ms |
3308 KB |
Output is correct |
18 |
Correct |
56 ms |
3308 KB |
Output is correct |
19 |
Correct |
57 ms |
3232 KB |
Output is correct |
20 |
Correct |
65 ms |
3308 KB |
Output is correct |
21 |
Correct |
135 ms |
3308 KB |
Output is correct |
22 |
Correct |
160 ms |
3308 KB |
Output is correct |
23 |
Correct |
108 ms |
3436 KB |
Output is correct |
24 |
Correct |
199 ms |
3436 KB |
Output is correct |
25 |
Correct |
201 ms |
3308 KB |
Output is correct |
26 |
Correct |
213 ms |
3436 KB |
Output is correct |
27 |
Correct |
214 ms |
3308 KB |
Output is correct |
28 |
Correct |
214 ms |
3308 KB |
Output is correct |
29 |
Correct |
213 ms |
3436 KB |
Output is correct |
30 |
Correct |
1 ms |
1260 KB |
Output is correct |
31 |
Correct |
211 ms |
3308 KB |
Output is correct |
32 |
Correct |
212 ms |
3436 KB |
Output is correct |
33 |
Correct |
212 ms |
3436 KB |
Output is correct |
34 |
Correct |
211 ms |
3308 KB |
Output is correct |
35 |
Correct |
202 ms |
3308 KB |
Output is correct |
36 |
Correct |
219 ms |
3308 KB |
Output is correct |
37 |
Correct |
424 ms |
3564 KB |
Output is correct |
38 |
Correct |
424 ms |
3436 KB |
Output is correct |
39 |
Correct |
521 ms |
3308 KB |
Output is correct |
40 |
Correct |
566 ms |
3564 KB |
Output is correct |
41 |
Correct |
568 ms |
3308 KB |
Output is correct |
42 |
Correct |
529 ms |
3488 KB |
Output is correct |
43 |
Correct |
517 ms |
3820 KB |
Output is correct |
44 |
Correct |
523 ms |
3692 KB |
Output is correct |
45 |
Correct |
527 ms |
3820 KB |
Output is correct |
46 |
Correct |
571 ms |
3436 KB |
Output is correct |
47 |
Correct |
524 ms |
3564 KB |
Output is correct |
48 |
Correct |
520 ms |
3616 KB |
Output is correct |
49 |
Correct |
532 ms |
3436 KB |
Output is correct |
50 |
Correct |
508 ms |
3564 KB |
Output is correct |
51 |
Correct |
1 ms |
1260 KB |
Output is correct |
52 |
Correct |
569 ms |
3692 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
3308 KB |
Output is correct |
2 |
Correct |
16 ms |
3308 KB |
Output is correct |
3 |
Correct |
5 ms |
2284 KB |
Output is correct |
4 |
Correct |
11 ms |
3308 KB |
Output is correct |
5 |
Correct |
28 ms |
3308 KB |
Output is correct |
6 |
Correct |
20 ms |
3308 KB |
Output is correct |
7 |
Correct |
15 ms |
3308 KB |
Output is correct |
8 |
Correct |
28 ms |
3308 KB |
Output is correct |
9 |
Correct |
1 ms |
1260 KB |
Output is correct |
10 |
Correct |
65 ms |
3308 KB |
Output is correct |
11 |
Correct |
65 ms |
3308 KB |
Output is correct |
12 |
Correct |
67 ms |
3436 KB |
Output is correct |
13 |
Correct |
1 ms |
1260 KB |
Output is correct |
14 |
Correct |
64 ms |
3312 KB |
Output is correct |
15 |
Correct |
61 ms |
3232 KB |
Output is correct |
16 |
Correct |
66 ms |
3308 KB |
Output is correct |
17 |
Correct |
41 ms |
3308 KB |
Output is correct |
18 |
Correct |
56 ms |
3308 KB |
Output is correct |
19 |
Correct |
57 ms |
3232 KB |
Output is correct |
20 |
Correct |
65 ms |
3308 KB |
Output is correct |
21 |
Correct |
135 ms |
3308 KB |
Output is correct |
22 |
Correct |
160 ms |
3308 KB |
Output is correct |
23 |
Correct |
108 ms |
3436 KB |
Output is correct |
24 |
Correct |
199 ms |
3436 KB |
Output is correct |
25 |
Correct |
201 ms |
3308 KB |
Output is correct |
26 |
Correct |
213 ms |
3436 KB |
Output is correct |
27 |
Correct |
214 ms |
3308 KB |
Output is correct |
28 |
Correct |
214 ms |
3308 KB |
Output is correct |
29 |
Correct |
213 ms |
3436 KB |
Output is correct |
30 |
Correct |
1 ms |
1260 KB |
Output is correct |
31 |
Correct |
211 ms |
3308 KB |
Output is correct |
32 |
Correct |
212 ms |
3436 KB |
Output is correct |
33 |
Correct |
212 ms |
3436 KB |
Output is correct |
34 |
Correct |
211 ms |
3308 KB |
Output is correct |
35 |
Correct |
202 ms |
3308 KB |
Output is correct |
36 |
Correct |
219 ms |
3308 KB |
Output is correct |
37 |
Correct |
424 ms |
3564 KB |
Output is correct |
38 |
Correct |
424 ms |
3436 KB |
Output is correct |
39 |
Correct |
521 ms |
3308 KB |
Output is correct |
40 |
Correct |
566 ms |
3564 KB |
Output is correct |
41 |
Correct |
568 ms |
3308 KB |
Output is correct |
42 |
Correct |
529 ms |
3488 KB |
Output is correct |
43 |
Correct |
517 ms |
3820 KB |
Output is correct |
44 |
Correct |
523 ms |
3692 KB |
Output is correct |
45 |
Correct |
527 ms |
3820 KB |
Output is correct |
46 |
Correct |
571 ms |
3436 KB |
Output is correct |
47 |
Correct |
524 ms |
3564 KB |
Output is correct |
48 |
Correct |
520 ms |
3616 KB |
Output is correct |
49 |
Correct |
532 ms |
3436 KB |
Output is correct |
50 |
Correct |
508 ms |
3564 KB |
Output is correct |
51 |
Correct |
1 ms |
1260 KB |
Output is correct |
52 |
Correct |
569 ms |
3692 KB |
Output is correct |
53 |
Correct |
635 ms |
3564 KB |
Output is correct |
54 |
Correct |
737 ms |
3692 KB |
Output is correct |
55 |
Correct |
734 ms |
3944 KB |
Output is correct |
56 |
Correct |
640 ms |
3692 KB |
Output is correct |
57 |
Correct |
747 ms |
4072 KB |
Output is correct |
58 |
Correct |
736 ms |
3820 KB |
Output is correct |
59 |
Correct |
741 ms |
3816 KB |
Output is correct |
60 |
Correct |
1 ms |
1260 KB |
Output is correct |
61 |
Correct |
746 ms |
3816 KB |
Output is correct |
62 |
Correct |
671 ms |
3868 KB |
Output is correct |
63 |
Correct |
683 ms |
3816 KB |
Output is correct |
64 |
Correct |
676 ms |
3944 KB |
Output is correct |
65 |
Correct |
669 ms |
3488 KB |
Output is correct |
66 |
Correct |
654 ms |
3436 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
3308 KB |
Output is correct |
2 |
Correct |
16 ms |
3308 KB |
Output is correct |
3 |
Correct |
5 ms |
2284 KB |
Output is correct |
4 |
Correct |
11 ms |
3308 KB |
Output is correct |
5 |
Correct |
28 ms |
3308 KB |
Output is correct |
6 |
Correct |
20 ms |
3308 KB |
Output is correct |
7 |
Correct |
15 ms |
3308 KB |
Output is correct |
8 |
Correct |
28 ms |
3308 KB |
Output is correct |
9 |
Correct |
1 ms |
1260 KB |
Output is correct |
10 |
Correct |
65 ms |
3308 KB |
Output is correct |
11 |
Correct |
65 ms |
3308 KB |
Output is correct |
12 |
Correct |
67 ms |
3436 KB |
Output is correct |
13 |
Correct |
1 ms |
1260 KB |
Output is correct |
14 |
Correct |
64 ms |
3312 KB |
Output is correct |
15 |
Correct |
61 ms |
3232 KB |
Output is correct |
16 |
Correct |
66 ms |
3308 KB |
Output is correct |
17 |
Correct |
41 ms |
3308 KB |
Output is correct |
18 |
Correct |
56 ms |
3308 KB |
Output is correct |
19 |
Correct |
57 ms |
3232 KB |
Output is correct |
20 |
Correct |
65 ms |
3308 KB |
Output is correct |
21 |
Correct |
135 ms |
3308 KB |
Output is correct |
22 |
Correct |
160 ms |
3308 KB |
Output is correct |
23 |
Correct |
108 ms |
3436 KB |
Output is correct |
24 |
Correct |
199 ms |
3436 KB |
Output is correct |
25 |
Correct |
201 ms |
3308 KB |
Output is correct |
26 |
Correct |
213 ms |
3436 KB |
Output is correct |
27 |
Correct |
214 ms |
3308 KB |
Output is correct |
28 |
Correct |
214 ms |
3308 KB |
Output is correct |
29 |
Correct |
213 ms |
3436 KB |
Output is correct |
30 |
Correct |
1 ms |
1260 KB |
Output is correct |
31 |
Correct |
211 ms |
3308 KB |
Output is correct |
32 |
Correct |
212 ms |
3436 KB |
Output is correct |
33 |
Correct |
212 ms |
3436 KB |
Output is correct |
34 |
Correct |
211 ms |
3308 KB |
Output is correct |
35 |
Correct |
202 ms |
3308 KB |
Output is correct |
36 |
Correct |
219 ms |
3308 KB |
Output is correct |
37 |
Correct |
424 ms |
3564 KB |
Output is correct |
38 |
Correct |
424 ms |
3436 KB |
Output is correct |
39 |
Correct |
521 ms |
3308 KB |
Output is correct |
40 |
Correct |
566 ms |
3564 KB |
Output is correct |
41 |
Correct |
568 ms |
3308 KB |
Output is correct |
42 |
Correct |
529 ms |
3488 KB |
Output is correct |
43 |
Correct |
517 ms |
3820 KB |
Output is correct |
44 |
Correct |
523 ms |
3692 KB |
Output is correct |
45 |
Correct |
527 ms |
3820 KB |
Output is correct |
46 |
Correct |
571 ms |
3436 KB |
Output is correct |
47 |
Correct |
524 ms |
3564 KB |
Output is correct |
48 |
Correct |
520 ms |
3616 KB |
Output is correct |
49 |
Correct |
532 ms |
3436 KB |
Output is correct |
50 |
Correct |
508 ms |
3564 KB |
Output is correct |
51 |
Correct |
1 ms |
1260 KB |
Output is correct |
52 |
Correct |
569 ms |
3692 KB |
Output is correct |
53 |
Correct |
635 ms |
3564 KB |
Output is correct |
54 |
Correct |
737 ms |
3692 KB |
Output is correct |
55 |
Correct |
734 ms |
3944 KB |
Output is correct |
56 |
Correct |
640 ms |
3692 KB |
Output is correct |
57 |
Correct |
747 ms |
4072 KB |
Output is correct |
58 |
Correct |
736 ms |
3820 KB |
Output is correct |
59 |
Correct |
741 ms |
3816 KB |
Output is correct |
60 |
Correct |
1 ms |
1260 KB |
Output is correct |
61 |
Correct |
746 ms |
3816 KB |
Output is correct |
62 |
Correct |
671 ms |
3868 KB |
Output is correct |
63 |
Correct |
683 ms |
3816 KB |
Output is correct |
64 |
Correct |
676 ms |
3944 KB |
Output is correct |
65 |
Correct |
669 ms |
3488 KB |
Output is correct |
66 |
Correct |
654 ms |
3436 KB |
Output is correct |
67 |
Correct |
847 ms |
3868 KB |
Output is correct |
68 |
Correct |
429 ms |
2284 KB |
Output is correct |
69 |
Execution timed out |
1074 ms |
4580 KB |
Time limit exceeded |
70 |
Halted |
0 ms |
0 KB |
- |