#include<bits/stdc++.h>
using namespace std;
#define int long long
#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+33;
const int MX = 2e5+5e4+10;
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 l[MX];
int r[MX];
int st;
void kill(int x)
{
if(x == st)
st = r[st];
else
{
r[l[x]] = r[x];
l[r[x]] = l[x];
}
}
signed main()
{
fast();
for(int i = 1; i < MX; i++)
{
l[i] = i-1;
r[i] = i+1;
}
r[0] = 1;
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 = st; V < MX; V = r[V])
{
int D = S+V-a[i];
if(D%2)
kill(V);
if(dp[(D/2)] || ((D >= 2*V) && ((dp[(D/2)-V]))))
continue;
kill(V);
}
add(a[i]);
}
vector<int> v;
for(int V = st; V < MX; V = r[V])
v.pb(V);
cout << v.size() << "\n";
for(int x: v)
cout << x << " ";
cout << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
6232 KB |
Output is correct |
2 |
Correct |
9 ms |
6236 KB |
Output is correct |
3 |
Correct |
3 ms |
6236 KB |
Output is correct |
4 |
Correct |
7 ms |
6236 KB |
Output is correct |
5 |
Correct |
15 ms |
6236 KB |
Output is correct |
6 |
Correct |
10 ms |
6236 KB |
Output is correct |
7 |
Correct |
9 ms |
6236 KB |
Output is correct |
8 |
Correct |
14 ms |
6236 KB |
Output is correct |
9 |
Correct |
12 ms |
6236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
6232 KB |
Output is correct |
2 |
Correct |
9 ms |
6236 KB |
Output is correct |
3 |
Correct |
3 ms |
6236 KB |
Output is correct |
4 |
Correct |
7 ms |
6236 KB |
Output is correct |
5 |
Correct |
15 ms |
6236 KB |
Output is correct |
6 |
Correct |
10 ms |
6236 KB |
Output is correct |
7 |
Correct |
9 ms |
6236 KB |
Output is correct |
8 |
Correct |
14 ms |
6236 KB |
Output is correct |
9 |
Correct |
12 ms |
6236 KB |
Output is correct |
10 |
Correct |
33 ms |
6236 KB |
Output is correct |
11 |
Correct |
37 ms |
6236 KB |
Output is correct |
12 |
Correct |
33 ms |
6236 KB |
Output is correct |
13 |
Correct |
30 ms |
6236 KB |
Output is correct |
14 |
Correct |
32 ms |
6236 KB |
Output is correct |
15 |
Correct |
35 ms |
6236 KB |
Output is correct |
16 |
Correct |
39 ms |
6236 KB |
Output is correct |
17 |
Correct |
22 ms |
6236 KB |
Output is correct |
18 |
Correct |
28 ms |
6236 KB |
Output is correct |
19 |
Correct |
31 ms |
6332 KB |
Output is correct |
20 |
Correct |
36 ms |
6564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
6232 KB |
Output is correct |
2 |
Correct |
9 ms |
6236 KB |
Output is correct |
3 |
Correct |
3 ms |
6236 KB |
Output is correct |
4 |
Correct |
7 ms |
6236 KB |
Output is correct |
5 |
Correct |
15 ms |
6236 KB |
Output is correct |
6 |
Correct |
10 ms |
6236 KB |
Output is correct |
7 |
Correct |
9 ms |
6236 KB |
Output is correct |
8 |
Correct |
14 ms |
6236 KB |
Output is correct |
9 |
Correct |
12 ms |
6236 KB |
Output is correct |
10 |
Correct |
33 ms |
6236 KB |
Output is correct |
11 |
Correct |
37 ms |
6236 KB |
Output is correct |
12 |
Correct |
33 ms |
6236 KB |
Output is correct |
13 |
Correct |
30 ms |
6236 KB |
Output is correct |
14 |
Correct |
32 ms |
6236 KB |
Output is correct |
15 |
Correct |
35 ms |
6236 KB |
Output is correct |
16 |
Correct |
39 ms |
6236 KB |
Output is correct |
17 |
Correct |
22 ms |
6236 KB |
Output is correct |
18 |
Correct |
28 ms |
6236 KB |
Output is correct |
19 |
Correct |
31 ms |
6332 KB |
Output is correct |
20 |
Correct |
36 ms |
6564 KB |
Output is correct |
21 |
Correct |
67 ms |
6320 KB |
Output is correct |
22 |
Correct |
77 ms |
6236 KB |
Output is correct |
23 |
Correct |
55 ms |
6296 KB |
Output is correct |
24 |
Correct |
98 ms |
6316 KB |
Output is correct |
25 |
Correct |
99 ms |
6480 KB |
Output is correct |
26 |
Correct |
101 ms |
6300 KB |
Output is correct |
27 |
Correct |
100 ms |
6236 KB |
Output is correct |
28 |
Correct |
100 ms |
6236 KB |
Output is correct |
29 |
Correct |
107 ms |
6484 KB |
Output is correct |
30 |
Correct |
100 ms |
6236 KB |
Output is correct |
31 |
Correct |
101 ms |
6232 KB |
Output is correct |
32 |
Correct |
103 ms |
6232 KB |
Output is correct |
33 |
Correct |
105 ms |
6296 KB |
Output is correct |
34 |
Correct |
105 ms |
6296 KB |
Output is correct |
35 |
Correct |
100 ms |
6232 KB |
Output is correct |
36 |
Correct |
111 ms |
6304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
6232 KB |
Output is correct |
2 |
Correct |
9 ms |
6236 KB |
Output is correct |
3 |
Correct |
3 ms |
6236 KB |
Output is correct |
4 |
Correct |
7 ms |
6236 KB |
Output is correct |
5 |
Correct |
15 ms |
6236 KB |
Output is correct |
6 |
Correct |
10 ms |
6236 KB |
Output is correct |
7 |
Correct |
9 ms |
6236 KB |
Output is correct |
8 |
Correct |
14 ms |
6236 KB |
Output is correct |
9 |
Correct |
12 ms |
6236 KB |
Output is correct |
10 |
Correct |
33 ms |
6236 KB |
Output is correct |
11 |
Correct |
37 ms |
6236 KB |
Output is correct |
12 |
Correct |
33 ms |
6236 KB |
Output is correct |
13 |
Correct |
30 ms |
6236 KB |
Output is correct |
14 |
Correct |
32 ms |
6236 KB |
Output is correct |
15 |
Correct |
35 ms |
6236 KB |
Output is correct |
16 |
Correct |
39 ms |
6236 KB |
Output is correct |
17 |
Correct |
22 ms |
6236 KB |
Output is correct |
18 |
Correct |
28 ms |
6236 KB |
Output is correct |
19 |
Correct |
31 ms |
6332 KB |
Output is correct |
20 |
Correct |
36 ms |
6564 KB |
Output is correct |
21 |
Correct |
67 ms |
6320 KB |
Output is correct |
22 |
Correct |
77 ms |
6236 KB |
Output is correct |
23 |
Correct |
55 ms |
6296 KB |
Output is correct |
24 |
Correct |
98 ms |
6316 KB |
Output is correct |
25 |
Correct |
99 ms |
6480 KB |
Output is correct |
26 |
Correct |
101 ms |
6300 KB |
Output is correct |
27 |
Correct |
100 ms |
6236 KB |
Output is correct |
28 |
Correct |
100 ms |
6236 KB |
Output is correct |
29 |
Correct |
107 ms |
6484 KB |
Output is correct |
30 |
Correct |
100 ms |
6236 KB |
Output is correct |
31 |
Correct |
101 ms |
6232 KB |
Output is correct |
32 |
Correct |
103 ms |
6232 KB |
Output is correct |
33 |
Correct |
105 ms |
6296 KB |
Output is correct |
34 |
Correct |
105 ms |
6296 KB |
Output is correct |
35 |
Correct |
100 ms |
6232 KB |
Output is correct |
36 |
Correct |
111 ms |
6304 KB |
Output is correct |
37 |
Correct |
208 ms |
6556 KB |
Output is correct |
38 |
Correct |
203 ms |
6480 KB |
Output is correct |
39 |
Correct |
244 ms |
6304 KB |
Output is correct |
40 |
Correct |
278 ms |
6560 KB |
Output is correct |
41 |
Correct |
268 ms |
6236 KB |
Output is correct |
42 |
Correct |
259 ms |
6740 KB |
Output is correct |
43 |
Correct |
251 ms |
6612 KB |
Output is correct |
44 |
Correct |
264 ms |
6684 KB |
Output is correct |
45 |
Correct |
259 ms |
6684 KB |
Output is correct |
46 |
Correct |
279 ms |
6232 KB |
Output is correct |
47 |
Correct |
262 ms |
6556 KB |
Output is correct |
48 |
Correct |
255 ms |
6612 KB |
Output is correct |
49 |
Correct |
251 ms |
6236 KB |
Output is correct |
50 |
Correct |
266 ms |
6572 KB |
Output is correct |
51 |
Correct |
81 ms |
6232 KB |
Output is correct |
52 |
Correct |
295 ms |
6684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
6232 KB |
Output is correct |
2 |
Correct |
9 ms |
6236 KB |
Output is correct |
3 |
Correct |
3 ms |
6236 KB |
Output is correct |
4 |
Correct |
7 ms |
6236 KB |
Output is correct |
5 |
Correct |
15 ms |
6236 KB |
Output is correct |
6 |
Correct |
10 ms |
6236 KB |
Output is correct |
7 |
Correct |
9 ms |
6236 KB |
Output is correct |
8 |
Correct |
14 ms |
6236 KB |
Output is correct |
9 |
Correct |
12 ms |
6236 KB |
Output is correct |
10 |
Correct |
33 ms |
6236 KB |
Output is correct |
11 |
Correct |
37 ms |
6236 KB |
Output is correct |
12 |
Correct |
33 ms |
6236 KB |
Output is correct |
13 |
Correct |
30 ms |
6236 KB |
Output is correct |
14 |
Correct |
32 ms |
6236 KB |
Output is correct |
15 |
Correct |
35 ms |
6236 KB |
Output is correct |
16 |
Correct |
39 ms |
6236 KB |
Output is correct |
17 |
Correct |
22 ms |
6236 KB |
Output is correct |
18 |
Correct |
28 ms |
6236 KB |
Output is correct |
19 |
Correct |
31 ms |
6332 KB |
Output is correct |
20 |
Correct |
36 ms |
6564 KB |
Output is correct |
21 |
Correct |
67 ms |
6320 KB |
Output is correct |
22 |
Correct |
77 ms |
6236 KB |
Output is correct |
23 |
Correct |
55 ms |
6296 KB |
Output is correct |
24 |
Correct |
98 ms |
6316 KB |
Output is correct |
25 |
Correct |
99 ms |
6480 KB |
Output is correct |
26 |
Correct |
101 ms |
6300 KB |
Output is correct |
27 |
Correct |
100 ms |
6236 KB |
Output is correct |
28 |
Correct |
100 ms |
6236 KB |
Output is correct |
29 |
Correct |
107 ms |
6484 KB |
Output is correct |
30 |
Correct |
100 ms |
6236 KB |
Output is correct |
31 |
Correct |
101 ms |
6232 KB |
Output is correct |
32 |
Correct |
103 ms |
6232 KB |
Output is correct |
33 |
Correct |
105 ms |
6296 KB |
Output is correct |
34 |
Correct |
105 ms |
6296 KB |
Output is correct |
35 |
Correct |
100 ms |
6232 KB |
Output is correct |
36 |
Correct |
111 ms |
6304 KB |
Output is correct |
37 |
Correct |
208 ms |
6556 KB |
Output is correct |
38 |
Correct |
203 ms |
6480 KB |
Output is correct |
39 |
Correct |
244 ms |
6304 KB |
Output is correct |
40 |
Correct |
278 ms |
6560 KB |
Output is correct |
41 |
Correct |
268 ms |
6236 KB |
Output is correct |
42 |
Correct |
259 ms |
6740 KB |
Output is correct |
43 |
Correct |
251 ms |
6612 KB |
Output is correct |
44 |
Correct |
264 ms |
6684 KB |
Output is correct |
45 |
Correct |
259 ms |
6684 KB |
Output is correct |
46 |
Correct |
279 ms |
6232 KB |
Output is correct |
47 |
Correct |
262 ms |
6556 KB |
Output is correct |
48 |
Correct |
255 ms |
6612 KB |
Output is correct |
49 |
Correct |
251 ms |
6236 KB |
Output is correct |
50 |
Correct |
266 ms |
6572 KB |
Output is correct |
51 |
Correct |
81 ms |
6232 KB |
Output is correct |
52 |
Correct |
295 ms |
6684 KB |
Output is correct |
53 |
Correct |
305 ms |
6688 KB |
Output is correct |
54 |
Correct |
364 ms |
6612 KB |
Output is correct |
55 |
Correct |
372 ms |
7116 KB |
Output is correct |
56 |
Correct |
324 ms |
6864 KB |
Output is correct |
57 |
Correct |
377 ms |
7120 KB |
Output is correct |
58 |
Correct |
373 ms |
6864 KB |
Output is correct |
59 |
Correct |
375 ms |
6868 KB |
Output is correct |
60 |
Correct |
121 ms |
6232 KB |
Output is correct |
61 |
Correct |
378 ms |
6956 KB |
Output is correct |
62 |
Correct |
350 ms |
6944 KB |
Output is correct |
63 |
Correct |
340 ms |
6868 KB |
Output is correct |
64 |
Correct |
339 ms |
6868 KB |
Output is correct |
65 |
Correct |
325 ms |
6232 KB |
Output is correct |
66 |
Correct |
308 ms |
6236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
6232 KB |
Output is correct |
2 |
Correct |
9 ms |
6236 KB |
Output is correct |
3 |
Correct |
3 ms |
6236 KB |
Output is correct |
4 |
Correct |
7 ms |
6236 KB |
Output is correct |
5 |
Correct |
15 ms |
6236 KB |
Output is correct |
6 |
Correct |
10 ms |
6236 KB |
Output is correct |
7 |
Correct |
9 ms |
6236 KB |
Output is correct |
8 |
Correct |
14 ms |
6236 KB |
Output is correct |
9 |
Correct |
12 ms |
6236 KB |
Output is correct |
10 |
Correct |
33 ms |
6236 KB |
Output is correct |
11 |
Correct |
37 ms |
6236 KB |
Output is correct |
12 |
Correct |
33 ms |
6236 KB |
Output is correct |
13 |
Correct |
30 ms |
6236 KB |
Output is correct |
14 |
Correct |
32 ms |
6236 KB |
Output is correct |
15 |
Correct |
35 ms |
6236 KB |
Output is correct |
16 |
Correct |
39 ms |
6236 KB |
Output is correct |
17 |
Correct |
22 ms |
6236 KB |
Output is correct |
18 |
Correct |
28 ms |
6236 KB |
Output is correct |
19 |
Correct |
31 ms |
6332 KB |
Output is correct |
20 |
Correct |
36 ms |
6564 KB |
Output is correct |
21 |
Correct |
67 ms |
6320 KB |
Output is correct |
22 |
Correct |
77 ms |
6236 KB |
Output is correct |
23 |
Correct |
55 ms |
6296 KB |
Output is correct |
24 |
Correct |
98 ms |
6316 KB |
Output is correct |
25 |
Correct |
99 ms |
6480 KB |
Output is correct |
26 |
Correct |
101 ms |
6300 KB |
Output is correct |
27 |
Correct |
100 ms |
6236 KB |
Output is correct |
28 |
Correct |
100 ms |
6236 KB |
Output is correct |
29 |
Correct |
107 ms |
6484 KB |
Output is correct |
30 |
Correct |
100 ms |
6236 KB |
Output is correct |
31 |
Correct |
101 ms |
6232 KB |
Output is correct |
32 |
Correct |
103 ms |
6232 KB |
Output is correct |
33 |
Correct |
105 ms |
6296 KB |
Output is correct |
34 |
Correct |
105 ms |
6296 KB |
Output is correct |
35 |
Correct |
100 ms |
6232 KB |
Output is correct |
36 |
Correct |
111 ms |
6304 KB |
Output is correct |
37 |
Correct |
208 ms |
6556 KB |
Output is correct |
38 |
Correct |
203 ms |
6480 KB |
Output is correct |
39 |
Correct |
244 ms |
6304 KB |
Output is correct |
40 |
Correct |
278 ms |
6560 KB |
Output is correct |
41 |
Correct |
268 ms |
6236 KB |
Output is correct |
42 |
Correct |
259 ms |
6740 KB |
Output is correct |
43 |
Correct |
251 ms |
6612 KB |
Output is correct |
44 |
Correct |
264 ms |
6684 KB |
Output is correct |
45 |
Correct |
259 ms |
6684 KB |
Output is correct |
46 |
Correct |
279 ms |
6232 KB |
Output is correct |
47 |
Correct |
262 ms |
6556 KB |
Output is correct |
48 |
Correct |
255 ms |
6612 KB |
Output is correct |
49 |
Correct |
251 ms |
6236 KB |
Output is correct |
50 |
Correct |
266 ms |
6572 KB |
Output is correct |
51 |
Correct |
81 ms |
6232 KB |
Output is correct |
52 |
Correct |
295 ms |
6684 KB |
Output is correct |
53 |
Correct |
305 ms |
6688 KB |
Output is correct |
54 |
Correct |
364 ms |
6612 KB |
Output is correct |
55 |
Correct |
372 ms |
7116 KB |
Output is correct |
56 |
Correct |
324 ms |
6864 KB |
Output is correct |
57 |
Correct |
377 ms |
7120 KB |
Output is correct |
58 |
Correct |
373 ms |
6864 KB |
Output is correct |
59 |
Correct |
375 ms |
6868 KB |
Output is correct |
60 |
Correct |
121 ms |
6232 KB |
Output is correct |
61 |
Correct |
378 ms |
6956 KB |
Output is correct |
62 |
Correct |
350 ms |
6944 KB |
Output is correct |
63 |
Correct |
340 ms |
6868 KB |
Output is correct |
64 |
Correct |
339 ms |
6868 KB |
Output is correct |
65 |
Correct |
325 ms |
6232 KB |
Output is correct |
66 |
Correct |
308 ms |
6236 KB |
Output is correct |
67 |
Correct |
424 ms |
6864 KB |
Output is correct |
68 |
Correct |
168 ms |
6308 KB |
Output is correct |
69 |
Correct |
574 ms |
7888 KB |
Output is correct |
70 |
Correct |
547 ms |
7380 KB |
Output is correct |
71 |
Correct |
543 ms |
7200 KB |
Output is correct |
72 |
Correct |
487 ms |
6232 KB |
Output is correct |
73 |
Correct |
492 ms |
6484 KB |
Output is correct |
74 |
Correct |
581 ms |
7964 KB |
Output is correct |
75 |
Correct |
558 ms |
7712 KB |
Output is correct |
76 |
Correct |
578 ms |
7736 KB |
Output is correct |
77 |
Correct |
584 ms |
8140 KB |
Output is correct |