#include<bits/stdc++.h>
using namespace std;
#define in array<int, 2>
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
const int mod = 1e9+9;
const int SMX = 2e5;
const int MX = 4e5;
int dp[MX];
void add(int x)
{
for(int i = MX-1; i >= x; i--)
{
dp[i]+=dp[i-x];
dp[i]%=mod;
}
return;
}
void rem(int x)
{
for(int i = x; i < MX; i++)
{
dp[i]-=dp[i-x]; dp[i]+=mod;
dp[i]%=mod;
}
return;
}
int cnt[SMX];
signed main()
{
fast();
dp[0] = 1;
int n;
cin >> n;
int S = 0;
vector<int> a(n+1);
for(int i = 1; i <= n; i++)
{
cin >> a[i]; S+=a[i];
add(a[i]);
}
if(S%2 || (dp[S/2] == 0))
{
cout << "0\n";
return 0;
}
for(int i = 1; i <= n; i++)
{
rem(a[i]);
for(int V = 0; V < SMX; V++)
{
int D = S+V-a[i];
if(D%2)
continue;
if(dp[(D/2)] || ((D >= 2*V) && ((dp[(D/2)-V]))))
cnt[V]++;
}
add(a[i]);
}
vector<int> v;
for(int i = 0; i < SMX; i++)
{
if(cnt[i] == n)
v.pb(i);
}
cout << v.size() << "\n";
for(int x: v)
cout << x << " ";
cout << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
2628 KB |
Output is correct |
2 |
Correct |
14 ms |
2628 KB |
Output is correct |
3 |
Correct |
2 ms |
2396 KB |
Output is correct |
4 |
Correct |
9 ms |
2632 KB |
Output is correct |
5 |
Correct |
25 ms |
2640 KB |
Output is correct |
6 |
Correct |
17 ms |
2396 KB |
Output is correct |
7 |
Correct |
13 ms |
2396 KB |
Output is correct |
8 |
Correct |
29 ms |
2628 KB |
Output is correct |
9 |
Correct |
21 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
2628 KB |
Output is correct |
2 |
Correct |
14 ms |
2628 KB |
Output is correct |
3 |
Correct |
2 ms |
2396 KB |
Output is correct |
4 |
Correct |
9 ms |
2632 KB |
Output is correct |
5 |
Correct |
25 ms |
2640 KB |
Output is correct |
6 |
Correct |
17 ms |
2396 KB |
Output is correct |
7 |
Correct |
13 ms |
2396 KB |
Output is correct |
8 |
Correct |
29 ms |
2628 KB |
Output is correct |
9 |
Correct |
21 ms |
2396 KB |
Output is correct |
10 |
Correct |
61 ms |
2396 KB |
Output is correct |
11 |
Correct |
69 ms |
2396 KB |
Output is correct |
12 |
Correct |
75 ms |
2392 KB |
Output is correct |
13 |
Correct |
56 ms |
2608 KB |
Output is correct |
14 |
Correct |
61 ms |
2396 KB |
Output is correct |
15 |
Correct |
70 ms |
2608 KB |
Output is correct |
16 |
Correct |
74 ms |
2648 KB |
Output is correct |
17 |
Correct |
40 ms |
2396 KB |
Output is correct |
18 |
Correct |
53 ms |
2608 KB |
Output is correct |
19 |
Correct |
57 ms |
2396 KB |
Output is correct |
20 |
Correct |
68 ms |
2612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
2628 KB |
Output is correct |
2 |
Correct |
14 ms |
2628 KB |
Output is correct |
3 |
Correct |
2 ms |
2396 KB |
Output is correct |
4 |
Correct |
9 ms |
2632 KB |
Output is correct |
5 |
Correct |
25 ms |
2640 KB |
Output is correct |
6 |
Correct |
17 ms |
2396 KB |
Output is correct |
7 |
Correct |
13 ms |
2396 KB |
Output is correct |
8 |
Correct |
29 ms |
2628 KB |
Output is correct |
9 |
Correct |
21 ms |
2396 KB |
Output is correct |
10 |
Correct |
61 ms |
2396 KB |
Output is correct |
11 |
Correct |
69 ms |
2396 KB |
Output is correct |
12 |
Correct |
75 ms |
2392 KB |
Output is correct |
13 |
Correct |
56 ms |
2608 KB |
Output is correct |
14 |
Correct |
61 ms |
2396 KB |
Output is correct |
15 |
Correct |
70 ms |
2608 KB |
Output is correct |
16 |
Correct |
74 ms |
2648 KB |
Output is correct |
17 |
Correct |
40 ms |
2396 KB |
Output is correct |
18 |
Correct |
53 ms |
2608 KB |
Output is correct |
19 |
Correct |
57 ms |
2396 KB |
Output is correct |
20 |
Correct |
68 ms |
2612 KB |
Output is correct |
21 |
Correct |
133 ms |
2640 KB |
Output is correct |
22 |
Correct |
152 ms |
2624 KB |
Output is correct |
23 |
Correct |
108 ms |
2620 KB |
Output is correct |
24 |
Correct |
193 ms |
2624 KB |
Output is correct |
25 |
Correct |
189 ms |
2624 KB |
Output is correct |
26 |
Correct |
217 ms |
2684 KB |
Output is correct |
27 |
Correct |
203 ms |
2636 KB |
Output is correct |
28 |
Correct |
198 ms |
2608 KB |
Output is correct |
29 |
Correct |
201 ms |
2648 KB |
Output is correct |
30 |
Correct |
203 ms |
2648 KB |
Output is correct |
31 |
Correct |
207 ms |
2632 KB |
Output is correct |
32 |
Correct |
202 ms |
2620 KB |
Output is correct |
33 |
Correct |
200 ms |
2652 KB |
Output is correct |
34 |
Correct |
201 ms |
2640 KB |
Output is correct |
35 |
Correct |
204 ms |
2644 KB |
Output is correct |
36 |
Correct |
206 ms |
2628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
2628 KB |
Output is correct |
2 |
Correct |
14 ms |
2628 KB |
Output is correct |
3 |
Correct |
2 ms |
2396 KB |
Output is correct |
4 |
Correct |
9 ms |
2632 KB |
Output is correct |
5 |
Correct |
25 ms |
2640 KB |
Output is correct |
6 |
Correct |
17 ms |
2396 KB |
Output is correct |
7 |
Correct |
13 ms |
2396 KB |
Output is correct |
8 |
Correct |
29 ms |
2628 KB |
Output is correct |
9 |
Correct |
21 ms |
2396 KB |
Output is correct |
10 |
Correct |
61 ms |
2396 KB |
Output is correct |
11 |
Correct |
69 ms |
2396 KB |
Output is correct |
12 |
Correct |
75 ms |
2392 KB |
Output is correct |
13 |
Correct |
56 ms |
2608 KB |
Output is correct |
14 |
Correct |
61 ms |
2396 KB |
Output is correct |
15 |
Correct |
70 ms |
2608 KB |
Output is correct |
16 |
Correct |
74 ms |
2648 KB |
Output is correct |
17 |
Correct |
40 ms |
2396 KB |
Output is correct |
18 |
Correct |
53 ms |
2608 KB |
Output is correct |
19 |
Correct |
57 ms |
2396 KB |
Output is correct |
20 |
Correct |
68 ms |
2612 KB |
Output is correct |
21 |
Correct |
133 ms |
2640 KB |
Output is correct |
22 |
Correct |
152 ms |
2624 KB |
Output is correct |
23 |
Correct |
108 ms |
2620 KB |
Output is correct |
24 |
Correct |
193 ms |
2624 KB |
Output is correct |
25 |
Correct |
189 ms |
2624 KB |
Output is correct |
26 |
Correct |
217 ms |
2684 KB |
Output is correct |
27 |
Correct |
203 ms |
2636 KB |
Output is correct |
28 |
Correct |
198 ms |
2608 KB |
Output is correct |
29 |
Correct |
201 ms |
2648 KB |
Output is correct |
30 |
Correct |
203 ms |
2648 KB |
Output is correct |
31 |
Correct |
207 ms |
2632 KB |
Output is correct |
32 |
Correct |
202 ms |
2620 KB |
Output is correct |
33 |
Correct |
200 ms |
2652 KB |
Output is correct |
34 |
Correct |
201 ms |
2640 KB |
Output is correct |
35 |
Correct |
204 ms |
2644 KB |
Output is correct |
36 |
Correct |
206 ms |
2628 KB |
Output is correct |
37 |
Correct |
404 ms |
2688 KB |
Output is correct |
38 |
Correct |
397 ms |
2640 KB |
Output is correct |
39 |
Correct |
508 ms |
2896 KB |
Output is correct |
40 |
Correct |
542 ms |
2728 KB |
Output is correct |
41 |
Correct |
541 ms |
2604 KB |
Output is correct |
42 |
Correct |
507 ms |
2896 KB |
Output is correct |
43 |
Correct |
485 ms |
3132 KB |
Output is correct |
44 |
Correct |
494 ms |
3156 KB |
Output is correct |
45 |
Correct |
514 ms |
3044 KB |
Output is correct |
46 |
Correct |
550 ms |
2736 KB |
Output is correct |
47 |
Correct |
507 ms |
2768 KB |
Output is correct |
48 |
Correct |
507 ms |
3152 KB |
Output is correct |
49 |
Correct |
493 ms |
2640 KB |
Output is correct |
50 |
Correct |
520 ms |
2740 KB |
Output is correct |
51 |
Correct |
143 ms |
2396 KB |
Output is correct |
52 |
Correct |
555 ms |
3040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
2628 KB |
Output is correct |
2 |
Correct |
14 ms |
2628 KB |
Output is correct |
3 |
Correct |
2 ms |
2396 KB |
Output is correct |
4 |
Correct |
9 ms |
2632 KB |
Output is correct |
5 |
Correct |
25 ms |
2640 KB |
Output is correct |
6 |
Correct |
17 ms |
2396 KB |
Output is correct |
7 |
Correct |
13 ms |
2396 KB |
Output is correct |
8 |
Correct |
29 ms |
2628 KB |
Output is correct |
9 |
Correct |
21 ms |
2396 KB |
Output is correct |
10 |
Correct |
61 ms |
2396 KB |
Output is correct |
11 |
Correct |
69 ms |
2396 KB |
Output is correct |
12 |
Correct |
75 ms |
2392 KB |
Output is correct |
13 |
Correct |
56 ms |
2608 KB |
Output is correct |
14 |
Correct |
61 ms |
2396 KB |
Output is correct |
15 |
Correct |
70 ms |
2608 KB |
Output is correct |
16 |
Correct |
74 ms |
2648 KB |
Output is correct |
17 |
Correct |
40 ms |
2396 KB |
Output is correct |
18 |
Correct |
53 ms |
2608 KB |
Output is correct |
19 |
Correct |
57 ms |
2396 KB |
Output is correct |
20 |
Correct |
68 ms |
2612 KB |
Output is correct |
21 |
Correct |
133 ms |
2640 KB |
Output is correct |
22 |
Correct |
152 ms |
2624 KB |
Output is correct |
23 |
Correct |
108 ms |
2620 KB |
Output is correct |
24 |
Correct |
193 ms |
2624 KB |
Output is correct |
25 |
Correct |
189 ms |
2624 KB |
Output is correct |
26 |
Correct |
217 ms |
2684 KB |
Output is correct |
27 |
Correct |
203 ms |
2636 KB |
Output is correct |
28 |
Correct |
198 ms |
2608 KB |
Output is correct |
29 |
Correct |
201 ms |
2648 KB |
Output is correct |
30 |
Correct |
203 ms |
2648 KB |
Output is correct |
31 |
Correct |
207 ms |
2632 KB |
Output is correct |
32 |
Correct |
202 ms |
2620 KB |
Output is correct |
33 |
Correct |
200 ms |
2652 KB |
Output is correct |
34 |
Correct |
201 ms |
2640 KB |
Output is correct |
35 |
Correct |
204 ms |
2644 KB |
Output is correct |
36 |
Correct |
206 ms |
2628 KB |
Output is correct |
37 |
Correct |
404 ms |
2688 KB |
Output is correct |
38 |
Correct |
397 ms |
2640 KB |
Output is correct |
39 |
Correct |
508 ms |
2896 KB |
Output is correct |
40 |
Correct |
542 ms |
2728 KB |
Output is correct |
41 |
Correct |
541 ms |
2604 KB |
Output is correct |
42 |
Correct |
507 ms |
2896 KB |
Output is correct |
43 |
Correct |
485 ms |
3132 KB |
Output is correct |
44 |
Correct |
494 ms |
3156 KB |
Output is correct |
45 |
Correct |
514 ms |
3044 KB |
Output is correct |
46 |
Correct |
550 ms |
2736 KB |
Output is correct |
47 |
Correct |
507 ms |
2768 KB |
Output is correct |
48 |
Correct |
507 ms |
3152 KB |
Output is correct |
49 |
Correct |
493 ms |
2640 KB |
Output is correct |
50 |
Correct |
520 ms |
2740 KB |
Output is correct |
51 |
Correct |
143 ms |
2396 KB |
Output is correct |
52 |
Correct |
555 ms |
3040 KB |
Output is correct |
53 |
Correct |
623 ms |
3044 KB |
Output is correct |
54 |
Correct |
708 ms |
3152 KB |
Output is correct |
55 |
Correct |
700 ms |
3284 KB |
Output is correct |
56 |
Correct |
603 ms |
3156 KB |
Output is correct |
57 |
Correct |
698 ms |
3428 KB |
Output is correct |
58 |
Correct |
699 ms |
3292 KB |
Output is correct |
59 |
Incorrect |
691 ms |
3284 KB |
Output isn't correct |
60 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
2628 KB |
Output is correct |
2 |
Correct |
14 ms |
2628 KB |
Output is correct |
3 |
Correct |
2 ms |
2396 KB |
Output is correct |
4 |
Correct |
9 ms |
2632 KB |
Output is correct |
5 |
Correct |
25 ms |
2640 KB |
Output is correct |
6 |
Correct |
17 ms |
2396 KB |
Output is correct |
7 |
Correct |
13 ms |
2396 KB |
Output is correct |
8 |
Correct |
29 ms |
2628 KB |
Output is correct |
9 |
Correct |
21 ms |
2396 KB |
Output is correct |
10 |
Correct |
61 ms |
2396 KB |
Output is correct |
11 |
Correct |
69 ms |
2396 KB |
Output is correct |
12 |
Correct |
75 ms |
2392 KB |
Output is correct |
13 |
Correct |
56 ms |
2608 KB |
Output is correct |
14 |
Correct |
61 ms |
2396 KB |
Output is correct |
15 |
Correct |
70 ms |
2608 KB |
Output is correct |
16 |
Correct |
74 ms |
2648 KB |
Output is correct |
17 |
Correct |
40 ms |
2396 KB |
Output is correct |
18 |
Correct |
53 ms |
2608 KB |
Output is correct |
19 |
Correct |
57 ms |
2396 KB |
Output is correct |
20 |
Correct |
68 ms |
2612 KB |
Output is correct |
21 |
Correct |
133 ms |
2640 KB |
Output is correct |
22 |
Correct |
152 ms |
2624 KB |
Output is correct |
23 |
Correct |
108 ms |
2620 KB |
Output is correct |
24 |
Correct |
193 ms |
2624 KB |
Output is correct |
25 |
Correct |
189 ms |
2624 KB |
Output is correct |
26 |
Correct |
217 ms |
2684 KB |
Output is correct |
27 |
Correct |
203 ms |
2636 KB |
Output is correct |
28 |
Correct |
198 ms |
2608 KB |
Output is correct |
29 |
Correct |
201 ms |
2648 KB |
Output is correct |
30 |
Correct |
203 ms |
2648 KB |
Output is correct |
31 |
Correct |
207 ms |
2632 KB |
Output is correct |
32 |
Correct |
202 ms |
2620 KB |
Output is correct |
33 |
Correct |
200 ms |
2652 KB |
Output is correct |
34 |
Correct |
201 ms |
2640 KB |
Output is correct |
35 |
Correct |
204 ms |
2644 KB |
Output is correct |
36 |
Correct |
206 ms |
2628 KB |
Output is correct |
37 |
Correct |
404 ms |
2688 KB |
Output is correct |
38 |
Correct |
397 ms |
2640 KB |
Output is correct |
39 |
Correct |
508 ms |
2896 KB |
Output is correct |
40 |
Correct |
542 ms |
2728 KB |
Output is correct |
41 |
Correct |
541 ms |
2604 KB |
Output is correct |
42 |
Correct |
507 ms |
2896 KB |
Output is correct |
43 |
Correct |
485 ms |
3132 KB |
Output is correct |
44 |
Correct |
494 ms |
3156 KB |
Output is correct |
45 |
Correct |
514 ms |
3044 KB |
Output is correct |
46 |
Correct |
550 ms |
2736 KB |
Output is correct |
47 |
Correct |
507 ms |
2768 KB |
Output is correct |
48 |
Correct |
507 ms |
3152 KB |
Output is correct |
49 |
Correct |
493 ms |
2640 KB |
Output is correct |
50 |
Correct |
520 ms |
2740 KB |
Output is correct |
51 |
Correct |
143 ms |
2396 KB |
Output is correct |
52 |
Correct |
555 ms |
3040 KB |
Output is correct |
53 |
Correct |
623 ms |
3044 KB |
Output is correct |
54 |
Correct |
708 ms |
3152 KB |
Output is correct |
55 |
Correct |
700 ms |
3284 KB |
Output is correct |
56 |
Correct |
603 ms |
3156 KB |
Output is correct |
57 |
Correct |
698 ms |
3428 KB |
Output is correct |
58 |
Correct |
699 ms |
3292 KB |
Output is correct |
59 |
Incorrect |
691 ms |
3284 KB |
Output isn't correct |
60 |
Halted |
0 ms |
0 KB |
- |