#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;
vi dp(M+510);
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cerr.tie(nullptr);
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 d(M+505, 0), cnt(M+505, 0), sol;
for (int i = 0; i < n; ++i){
fill(d.begin(), d.end(), 0);
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];
if (cnt[j] == n)
sol.push_back(j);
}
}
}
sort(sol.begin(), sol.end());
cout << (int)sol.size() << '\n';
for (auto& i : sol)
cout << i << ' ';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
3308 KB |
Output is correct |
2 |
Correct |
17 ms |
3308 KB |
Output is correct |
3 |
Correct |
4 ms |
1260 KB |
Output is correct |
4 |
Correct |
13 ms |
3308 KB |
Output is correct |
5 |
Correct |
34 ms |
3308 KB |
Output is correct |
6 |
Correct |
23 ms |
3308 KB |
Output is correct |
7 |
Correct |
18 ms |
3308 KB |
Output is correct |
8 |
Correct |
34 ms |
3308 KB |
Output is correct |
9 |
Correct |
1 ms |
1260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
3308 KB |
Output is correct |
2 |
Correct |
17 ms |
3308 KB |
Output is correct |
3 |
Correct |
4 ms |
1260 KB |
Output is correct |
4 |
Correct |
13 ms |
3308 KB |
Output is correct |
5 |
Correct |
34 ms |
3308 KB |
Output is correct |
6 |
Correct |
23 ms |
3308 KB |
Output is correct |
7 |
Correct |
18 ms |
3308 KB |
Output is correct |
8 |
Correct |
34 ms |
3308 KB |
Output is correct |
9 |
Correct |
1 ms |
1260 KB |
Output is correct |
10 |
Correct |
80 ms |
3308 KB |
Output is correct |
11 |
Correct |
80 ms |
3308 KB |
Output is correct |
12 |
Correct |
85 ms |
3436 KB |
Output is correct |
13 |
Correct |
1 ms |
1260 KB |
Output is correct |
14 |
Correct |
76 ms |
3308 KB |
Output is correct |
15 |
Correct |
76 ms |
3308 KB |
Output is correct |
16 |
Correct |
82 ms |
3436 KB |
Output is correct |
17 |
Correct |
50 ms |
3328 KB |
Output is correct |
18 |
Correct |
68 ms |
3308 KB |
Output is correct |
19 |
Correct |
71 ms |
3308 KB |
Output is correct |
20 |
Correct |
80 ms |
3308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
3308 KB |
Output is correct |
2 |
Correct |
17 ms |
3308 KB |
Output is correct |
3 |
Correct |
4 ms |
1260 KB |
Output is correct |
4 |
Correct |
13 ms |
3308 KB |
Output is correct |
5 |
Correct |
34 ms |
3308 KB |
Output is correct |
6 |
Correct |
23 ms |
3308 KB |
Output is correct |
7 |
Correct |
18 ms |
3308 KB |
Output is correct |
8 |
Correct |
34 ms |
3308 KB |
Output is correct |
9 |
Correct |
1 ms |
1260 KB |
Output is correct |
10 |
Correct |
80 ms |
3308 KB |
Output is correct |
11 |
Correct |
80 ms |
3308 KB |
Output is correct |
12 |
Correct |
85 ms |
3436 KB |
Output is correct |
13 |
Correct |
1 ms |
1260 KB |
Output is correct |
14 |
Correct |
76 ms |
3308 KB |
Output is correct |
15 |
Correct |
76 ms |
3308 KB |
Output is correct |
16 |
Correct |
82 ms |
3436 KB |
Output is correct |
17 |
Correct |
50 ms |
3328 KB |
Output is correct |
18 |
Correct |
68 ms |
3308 KB |
Output is correct |
19 |
Correct |
71 ms |
3308 KB |
Output is correct |
20 |
Correct |
80 ms |
3308 KB |
Output is correct |
21 |
Correct |
170 ms |
3180 KB |
Output is correct |
22 |
Correct |
200 ms |
3332 KB |
Output is correct |
23 |
Correct |
134 ms |
3308 KB |
Output is correct |
24 |
Correct |
249 ms |
3308 KB |
Output is correct |
25 |
Correct |
251 ms |
3436 KB |
Output is correct |
26 |
Correct |
263 ms |
3416 KB |
Output is correct |
27 |
Correct |
266 ms |
3308 KB |
Output is correct |
28 |
Correct |
265 ms |
3308 KB |
Output is correct |
29 |
Correct |
267 ms |
3436 KB |
Output is correct |
30 |
Correct |
1 ms |
1260 KB |
Output is correct |
31 |
Correct |
267 ms |
3436 KB |
Output is correct |
32 |
Correct |
264 ms |
3436 KB |
Output is correct |
33 |
Correct |
268 ms |
3436 KB |
Output is correct |
34 |
Correct |
264 ms |
3308 KB |
Output is correct |
35 |
Correct |
266 ms |
3340 KB |
Output is correct |
36 |
Correct |
266 ms |
3308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
3308 KB |
Output is correct |
2 |
Correct |
17 ms |
3308 KB |
Output is correct |
3 |
Correct |
4 ms |
1260 KB |
Output is correct |
4 |
Correct |
13 ms |
3308 KB |
Output is correct |
5 |
Correct |
34 ms |
3308 KB |
Output is correct |
6 |
Correct |
23 ms |
3308 KB |
Output is correct |
7 |
Correct |
18 ms |
3308 KB |
Output is correct |
8 |
Correct |
34 ms |
3308 KB |
Output is correct |
9 |
Correct |
1 ms |
1260 KB |
Output is correct |
10 |
Correct |
80 ms |
3308 KB |
Output is correct |
11 |
Correct |
80 ms |
3308 KB |
Output is correct |
12 |
Correct |
85 ms |
3436 KB |
Output is correct |
13 |
Correct |
1 ms |
1260 KB |
Output is correct |
14 |
Correct |
76 ms |
3308 KB |
Output is correct |
15 |
Correct |
76 ms |
3308 KB |
Output is correct |
16 |
Correct |
82 ms |
3436 KB |
Output is correct |
17 |
Correct |
50 ms |
3328 KB |
Output is correct |
18 |
Correct |
68 ms |
3308 KB |
Output is correct |
19 |
Correct |
71 ms |
3308 KB |
Output is correct |
20 |
Correct |
80 ms |
3308 KB |
Output is correct |
21 |
Correct |
170 ms |
3180 KB |
Output is correct |
22 |
Correct |
200 ms |
3332 KB |
Output is correct |
23 |
Correct |
134 ms |
3308 KB |
Output is correct |
24 |
Correct |
249 ms |
3308 KB |
Output is correct |
25 |
Correct |
251 ms |
3436 KB |
Output is correct |
26 |
Correct |
263 ms |
3416 KB |
Output is correct |
27 |
Correct |
266 ms |
3308 KB |
Output is correct |
28 |
Correct |
265 ms |
3308 KB |
Output is correct |
29 |
Correct |
267 ms |
3436 KB |
Output is correct |
30 |
Correct |
1 ms |
1260 KB |
Output is correct |
31 |
Correct |
267 ms |
3436 KB |
Output is correct |
32 |
Correct |
264 ms |
3436 KB |
Output is correct |
33 |
Correct |
268 ms |
3436 KB |
Output is correct |
34 |
Correct |
264 ms |
3308 KB |
Output is correct |
35 |
Correct |
266 ms |
3340 KB |
Output is correct |
36 |
Correct |
266 ms |
3308 KB |
Output is correct |
37 |
Correct |
534 ms |
3436 KB |
Output is correct |
38 |
Correct |
530 ms |
3416 KB |
Output is correct |
39 |
Correct |
655 ms |
3436 KB |
Output is correct |
40 |
Correct |
721 ms |
3564 KB |
Output is correct |
41 |
Correct |
714 ms |
3308 KB |
Output is correct |
42 |
Correct |
639 ms |
3436 KB |
Output is correct |
43 |
Correct |
656 ms |
3820 KB |
Output is correct |
44 |
Correct |
662 ms |
3692 KB |
Output is correct |
45 |
Correct |
667 ms |
3820 KB |
Output is correct |
46 |
Correct |
717 ms |
3436 KB |
Output is correct |
47 |
Correct |
665 ms |
3460 KB |
Output is correct |
48 |
Correct |
645 ms |
3608 KB |
Output is correct |
49 |
Correct |
639 ms |
3416 KB |
Output is correct |
50 |
Correct |
639 ms |
3436 KB |
Output is correct |
51 |
Correct |
1 ms |
1260 KB |
Output is correct |
52 |
Correct |
717 ms |
3820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
3308 KB |
Output is correct |
2 |
Correct |
17 ms |
3308 KB |
Output is correct |
3 |
Correct |
4 ms |
1260 KB |
Output is correct |
4 |
Correct |
13 ms |
3308 KB |
Output is correct |
5 |
Correct |
34 ms |
3308 KB |
Output is correct |
6 |
Correct |
23 ms |
3308 KB |
Output is correct |
7 |
Correct |
18 ms |
3308 KB |
Output is correct |
8 |
Correct |
34 ms |
3308 KB |
Output is correct |
9 |
Correct |
1 ms |
1260 KB |
Output is correct |
10 |
Correct |
80 ms |
3308 KB |
Output is correct |
11 |
Correct |
80 ms |
3308 KB |
Output is correct |
12 |
Correct |
85 ms |
3436 KB |
Output is correct |
13 |
Correct |
1 ms |
1260 KB |
Output is correct |
14 |
Correct |
76 ms |
3308 KB |
Output is correct |
15 |
Correct |
76 ms |
3308 KB |
Output is correct |
16 |
Correct |
82 ms |
3436 KB |
Output is correct |
17 |
Correct |
50 ms |
3328 KB |
Output is correct |
18 |
Correct |
68 ms |
3308 KB |
Output is correct |
19 |
Correct |
71 ms |
3308 KB |
Output is correct |
20 |
Correct |
80 ms |
3308 KB |
Output is correct |
21 |
Correct |
170 ms |
3180 KB |
Output is correct |
22 |
Correct |
200 ms |
3332 KB |
Output is correct |
23 |
Correct |
134 ms |
3308 KB |
Output is correct |
24 |
Correct |
249 ms |
3308 KB |
Output is correct |
25 |
Correct |
251 ms |
3436 KB |
Output is correct |
26 |
Correct |
263 ms |
3416 KB |
Output is correct |
27 |
Correct |
266 ms |
3308 KB |
Output is correct |
28 |
Correct |
265 ms |
3308 KB |
Output is correct |
29 |
Correct |
267 ms |
3436 KB |
Output is correct |
30 |
Correct |
1 ms |
1260 KB |
Output is correct |
31 |
Correct |
267 ms |
3436 KB |
Output is correct |
32 |
Correct |
264 ms |
3436 KB |
Output is correct |
33 |
Correct |
268 ms |
3436 KB |
Output is correct |
34 |
Correct |
264 ms |
3308 KB |
Output is correct |
35 |
Correct |
266 ms |
3340 KB |
Output is correct |
36 |
Correct |
266 ms |
3308 KB |
Output is correct |
37 |
Correct |
534 ms |
3436 KB |
Output is correct |
38 |
Correct |
530 ms |
3416 KB |
Output is correct |
39 |
Correct |
655 ms |
3436 KB |
Output is correct |
40 |
Correct |
721 ms |
3564 KB |
Output is correct |
41 |
Correct |
714 ms |
3308 KB |
Output is correct |
42 |
Correct |
639 ms |
3436 KB |
Output is correct |
43 |
Correct |
656 ms |
3820 KB |
Output is correct |
44 |
Correct |
662 ms |
3692 KB |
Output is correct |
45 |
Correct |
667 ms |
3820 KB |
Output is correct |
46 |
Correct |
717 ms |
3436 KB |
Output is correct |
47 |
Correct |
665 ms |
3460 KB |
Output is correct |
48 |
Correct |
645 ms |
3608 KB |
Output is correct |
49 |
Correct |
639 ms |
3416 KB |
Output is correct |
50 |
Correct |
639 ms |
3436 KB |
Output is correct |
51 |
Correct |
1 ms |
1260 KB |
Output is correct |
52 |
Correct |
717 ms |
3820 KB |
Output is correct |
53 |
Correct |
794 ms |
3692 KB |
Output is correct |
54 |
Correct |
935 ms |
3820 KB |
Output is correct |
55 |
Correct |
957 ms |
3932 KB |
Output is correct |
56 |
Correct |
817 ms |
3692 KB |
Output is correct |
57 |
Correct |
956 ms |
4080 KB |
Output is correct |
58 |
Correct |
936 ms |
3736 KB |
Output is correct |
59 |
Correct |
942 ms |
3824 KB |
Output is correct |
60 |
Correct |
1 ms |
1260 KB |
Output is correct |
61 |
Correct |
952 ms |
3848 KB |
Output is correct |
62 |
Correct |
869 ms |
3952 KB |
Output is correct |
63 |
Correct |
870 ms |
3952 KB |
Output is correct |
64 |
Correct |
861 ms |
3848 KB |
Output is correct |
65 |
Correct |
837 ms |
3436 KB |
Output is correct |
66 |
Correct |
819 ms |
3308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
3308 KB |
Output is correct |
2 |
Correct |
17 ms |
3308 KB |
Output is correct |
3 |
Correct |
4 ms |
1260 KB |
Output is correct |
4 |
Correct |
13 ms |
3308 KB |
Output is correct |
5 |
Correct |
34 ms |
3308 KB |
Output is correct |
6 |
Correct |
23 ms |
3308 KB |
Output is correct |
7 |
Correct |
18 ms |
3308 KB |
Output is correct |
8 |
Correct |
34 ms |
3308 KB |
Output is correct |
9 |
Correct |
1 ms |
1260 KB |
Output is correct |
10 |
Correct |
80 ms |
3308 KB |
Output is correct |
11 |
Correct |
80 ms |
3308 KB |
Output is correct |
12 |
Correct |
85 ms |
3436 KB |
Output is correct |
13 |
Correct |
1 ms |
1260 KB |
Output is correct |
14 |
Correct |
76 ms |
3308 KB |
Output is correct |
15 |
Correct |
76 ms |
3308 KB |
Output is correct |
16 |
Correct |
82 ms |
3436 KB |
Output is correct |
17 |
Correct |
50 ms |
3328 KB |
Output is correct |
18 |
Correct |
68 ms |
3308 KB |
Output is correct |
19 |
Correct |
71 ms |
3308 KB |
Output is correct |
20 |
Correct |
80 ms |
3308 KB |
Output is correct |
21 |
Correct |
170 ms |
3180 KB |
Output is correct |
22 |
Correct |
200 ms |
3332 KB |
Output is correct |
23 |
Correct |
134 ms |
3308 KB |
Output is correct |
24 |
Correct |
249 ms |
3308 KB |
Output is correct |
25 |
Correct |
251 ms |
3436 KB |
Output is correct |
26 |
Correct |
263 ms |
3416 KB |
Output is correct |
27 |
Correct |
266 ms |
3308 KB |
Output is correct |
28 |
Correct |
265 ms |
3308 KB |
Output is correct |
29 |
Correct |
267 ms |
3436 KB |
Output is correct |
30 |
Correct |
1 ms |
1260 KB |
Output is correct |
31 |
Correct |
267 ms |
3436 KB |
Output is correct |
32 |
Correct |
264 ms |
3436 KB |
Output is correct |
33 |
Correct |
268 ms |
3436 KB |
Output is correct |
34 |
Correct |
264 ms |
3308 KB |
Output is correct |
35 |
Correct |
266 ms |
3340 KB |
Output is correct |
36 |
Correct |
266 ms |
3308 KB |
Output is correct |
37 |
Correct |
534 ms |
3436 KB |
Output is correct |
38 |
Correct |
530 ms |
3416 KB |
Output is correct |
39 |
Correct |
655 ms |
3436 KB |
Output is correct |
40 |
Correct |
721 ms |
3564 KB |
Output is correct |
41 |
Correct |
714 ms |
3308 KB |
Output is correct |
42 |
Correct |
639 ms |
3436 KB |
Output is correct |
43 |
Correct |
656 ms |
3820 KB |
Output is correct |
44 |
Correct |
662 ms |
3692 KB |
Output is correct |
45 |
Correct |
667 ms |
3820 KB |
Output is correct |
46 |
Correct |
717 ms |
3436 KB |
Output is correct |
47 |
Correct |
665 ms |
3460 KB |
Output is correct |
48 |
Correct |
645 ms |
3608 KB |
Output is correct |
49 |
Correct |
639 ms |
3416 KB |
Output is correct |
50 |
Correct |
639 ms |
3436 KB |
Output is correct |
51 |
Correct |
1 ms |
1260 KB |
Output is correct |
52 |
Correct |
717 ms |
3820 KB |
Output is correct |
53 |
Correct |
794 ms |
3692 KB |
Output is correct |
54 |
Correct |
935 ms |
3820 KB |
Output is correct |
55 |
Correct |
957 ms |
3932 KB |
Output is correct |
56 |
Correct |
817 ms |
3692 KB |
Output is correct |
57 |
Correct |
956 ms |
4080 KB |
Output is correct |
58 |
Correct |
936 ms |
3736 KB |
Output is correct |
59 |
Correct |
942 ms |
3824 KB |
Output is correct |
60 |
Correct |
1 ms |
1260 KB |
Output is correct |
61 |
Correct |
952 ms |
3848 KB |
Output is correct |
62 |
Correct |
869 ms |
3952 KB |
Output is correct |
63 |
Correct |
870 ms |
3952 KB |
Output is correct |
64 |
Correct |
861 ms |
3848 KB |
Output is correct |
65 |
Correct |
837 ms |
3436 KB |
Output is correct |
66 |
Correct |
819 ms |
3308 KB |
Output is correct |
67 |
Execution timed out |
1077 ms |
3952 KB |
Time limit exceeded |
68 |
Halted |
0 ms |
0 KB |
- |