#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pr;
#define fr first
#define sc second
#define FOR(i, a) for (int i = 0; i < (a); i++)
#define F0R(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i,a) for (int i = (a)-1; i >= 0; i--)
#define F0Rd(i,a,b) for (int i = (b); i >= (a); i--)
#define trav(a, x) for (auto& a : x)
const int N=5000006;
int sum;
int a[N];
ll dp[N];
bool cant[N];
void add(ll k){
sum+=k;
for (int i=sum;i>=k;i--){
dp[i]+=dp[i-k];
}
}
void rem(ll k){
for (int i=k;i<=sum;i++){
dp[i]-=dp[i-k];
}
sum-=k;
}
int main(){
ios_base::sync_with_stdio(false);
#ifndef EVAL
freopen("input.txt","r",stdin);
#endif
int n;
cin>>n;
dp[0]=1;
FOR(i,n){
cin>>a[i];
add(a[i]);
}
if (sum%2==1 || dp[sum/2]==0){
//cout<<dp[sum/2]<<endl;
cout<<0<<endl;
return 0;
}
int hn=sum;
FOR(i,n){
rem(a[i]);
FOR(j,hn+1){
//cout<<a[i]<<" "<<j<<" "<<dp[j]<<endl;
if ((sum+j)%2==1 || dp[(sum+j)/2]==0){
cant[j]=true;
}
}
add(a[i]);
}
int ans=0;
FOR(j,hn+1)
if (!cant[j])
ans++;
cout<<ans<<endl;
FOR(j,hn+1)
if (!cant[j])
cout<<j<<" ";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
464 KB |
Output is correct |
4 |
Correct |
2 ms |
488 KB |
Output is correct |
5 |
Correct |
2 ms |
668 KB |
Output is correct |
6 |
Correct |
2 ms |
668 KB |
Output is correct |
7 |
Correct |
2 ms |
692 KB |
Output is correct |
8 |
Correct |
2 ms |
720 KB |
Output is correct |
9 |
Correct |
2 ms |
720 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
464 KB |
Output is correct |
4 |
Correct |
2 ms |
488 KB |
Output is correct |
5 |
Correct |
2 ms |
668 KB |
Output is correct |
6 |
Correct |
2 ms |
668 KB |
Output is correct |
7 |
Correct |
2 ms |
692 KB |
Output is correct |
8 |
Correct |
2 ms |
720 KB |
Output is correct |
9 |
Correct |
2 ms |
720 KB |
Output is correct |
10 |
Correct |
2 ms |
720 KB |
Output is correct |
11 |
Correct |
2 ms |
720 KB |
Output is correct |
12 |
Correct |
2 ms |
720 KB |
Output is correct |
13 |
Correct |
2 ms |
720 KB |
Output is correct |
14 |
Correct |
2 ms |
720 KB |
Output is correct |
15 |
Correct |
2 ms |
720 KB |
Output is correct |
16 |
Correct |
2 ms |
720 KB |
Output is correct |
17 |
Correct |
2 ms |
720 KB |
Output is correct |
18 |
Correct |
2 ms |
720 KB |
Output is correct |
19 |
Correct |
2 ms |
720 KB |
Output is correct |
20 |
Correct |
2 ms |
720 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
464 KB |
Output is correct |
4 |
Correct |
2 ms |
488 KB |
Output is correct |
5 |
Correct |
2 ms |
668 KB |
Output is correct |
6 |
Correct |
2 ms |
668 KB |
Output is correct |
7 |
Correct |
2 ms |
692 KB |
Output is correct |
8 |
Correct |
2 ms |
720 KB |
Output is correct |
9 |
Correct |
2 ms |
720 KB |
Output is correct |
10 |
Correct |
2 ms |
720 KB |
Output is correct |
11 |
Correct |
2 ms |
720 KB |
Output is correct |
12 |
Correct |
2 ms |
720 KB |
Output is correct |
13 |
Correct |
2 ms |
720 KB |
Output is correct |
14 |
Correct |
2 ms |
720 KB |
Output is correct |
15 |
Correct |
2 ms |
720 KB |
Output is correct |
16 |
Correct |
2 ms |
720 KB |
Output is correct |
17 |
Correct |
2 ms |
720 KB |
Output is correct |
18 |
Correct |
2 ms |
720 KB |
Output is correct |
19 |
Correct |
2 ms |
720 KB |
Output is correct |
20 |
Correct |
2 ms |
720 KB |
Output is correct |
21 |
Correct |
2 ms |
720 KB |
Output is correct |
22 |
Correct |
3 ms |
720 KB |
Output is correct |
23 |
Correct |
2 ms |
720 KB |
Output is correct |
24 |
Correct |
3 ms |
720 KB |
Output is correct |
25 |
Correct |
5 ms |
768 KB |
Output is correct |
26 |
Correct |
5 ms |
776 KB |
Output is correct |
27 |
Correct |
5 ms |
776 KB |
Output is correct |
28 |
Correct |
5 ms |
776 KB |
Output is correct |
29 |
Correct |
5 ms |
776 KB |
Output is correct |
30 |
Correct |
3 ms |
776 KB |
Output is correct |
31 |
Correct |
4 ms |
776 KB |
Output is correct |
32 |
Correct |
3 ms |
776 KB |
Output is correct |
33 |
Correct |
5 ms |
776 KB |
Output is correct |
34 |
Correct |
5 ms |
776 KB |
Output is correct |
35 |
Correct |
5 ms |
776 KB |
Output is correct |
36 |
Correct |
3 ms |
776 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
464 KB |
Output is correct |
4 |
Correct |
2 ms |
488 KB |
Output is correct |
5 |
Correct |
2 ms |
668 KB |
Output is correct |
6 |
Correct |
2 ms |
668 KB |
Output is correct |
7 |
Correct |
2 ms |
692 KB |
Output is correct |
8 |
Correct |
2 ms |
720 KB |
Output is correct |
9 |
Correct |
2 ms |
720 KB |
Output is correct |
10 |
Correct |
2 ms |
720 KB |
Output is correct |
11 |
Correct |
2 ms |
720 KB |
Output is correct |
12 |
Correct |
2 ms |
720 KB |
Output is correct |
13 |
Correct |
2 ms |
720 KB |
Output is correct |
14 |
Correct |
2 ms |
720 KB |
Output is correct |
15 |
Correct |
2 ms |
720 KB |
Output is correct |
16 |
Correct |
2 ms |
720 KB |
Output is correct |
17 |
Correct |
2 ms |
720 KB |
Output is correct |
18 |
Correct |
2 ms |
720 KB |
Output is correct |
19 |
Correct |
2 ms |
720 KB |
Output is correct |
20 |
Correct |
2 ms |
720 KB |
Output is correct |
21 |
Correct |
2 ms |
720 KB |
Output is correct |
22 |
Correct |
3 ms |
720 KB |
Output is correct |
23 |
Correct |
2 ms |
720 KB |
Output is correct |
24 |
Correct |
3 ms |
720 KB |
Output is correct |
25 |
Correct |
5 ms |
768 KB |
Output is correct |
26 |
Correct |
5 ms |
776 KB |
Output is correct |
27 |
Correct |
5 ms |
776 KB |
Output is correct |
28 |
Correct |
5 ms |
776 KB |
Output is correct |
29 |
Correct |
5 ms |
776 KB |
Output is correct |
30 |
Correct |
3 ms |
776 KB |
Output is correct |
31 |
Correct |
4 ms |
776 KB |
Output is correct |
32 |
Correct |
3 ms |
776 KB |
Output is correct |
33 |
Correct |
5 ms |
776 KB |
Output is correct |
34 |
Correct |
5 ms |
776 KB |
Output is correct |
35 |
Correct |
5 ms |
776 KB |
Output is correct |
36 |
Correct |
3 ms |
776 KB |
Output is correct |
37 |
Correct |
14 ms |
800 KB |
Output is correct |
38 |
Correct |
14 ms |
928 KB |
Output is correct |
39 |
Correct |
49 ms |
1240 KB |
Output is correct |
40 |
Correct |
28 ms |
1240 KB |
Output is correct |
41 |
Correct |
62 ms |
1440 KB |
Output is correct |
42 |
Correct |
26 ms |
1440 KB |
Output is correct |
43 |
Correct |
47 ms |
1440 KB |
Output is correct |
44 |
Correct |
47 ms |
1440 KB |
Output is correct |
45 |
Correct |
45 ms |
1440 KB |
Output is correct |
46 |
Correct |
31 ms |
1440 KB |
Output is correct |
47 |
Correct |
27 ms |
1440 KB |
Output is correct |
48 |
Correct |
51 ms |
1440 KB |
Output is correct |
49 |
Correct |
61 ms |
1440 KB |
Output is correct |
50 |
Correct |
27 ms |
1440 KB |
Output is correct |
51 |
Correct |
4 ms |
1440 KB |
Output is correct |
52 |
Correct |
61 ms |
1440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
464 KB |
Output is correct |
4 |
Correct |
2 ms |
488 KB |
Output is correct |
5 |
Correct |
2 ms |
668 KB |
Output is correct |
6 |
Correct |
2 ms |
668 KB |
Output is correct |
7 |
Correct |
2 ms |
692 KB |
Output is correct |
8 |
Correct |
2 ms |
720 KB |
Output is correct |
9 |
Correct |
2 ms |
720 KB |
Output is correct |
10 |
Correct |
2 ms |
720 KB |
Output is correct |
11 |
Correct |
2 ms |
720 KB |
Output is correct |
12 |
Correct |
2 ms |
720 KB |
Output is correct |
13 |
Correct |
2 ms |
720 KB |
Output is correct |
14 |
Correct |
2 ms |
720 KB |
Output is correct |
15 |
Correct |
2 ms |
720 KB |
Output is correct |
16 |
Correct |
2 ms |
720 KB |
Output is correct |
17 |
Correct |
2 ms |
720 KB |
Output is correct |
18 |
Correct |
2 ms |
720 KB |
Output is correct |
19 |
Correct |
2 ms |
720 KB |
Output is correct |
20 |
Correct |
2 ms |
720 KB |
Output is correct |
21 |
Correct |
2 ms |
720 KB |
Output is correct |
22 |
Correct |
3 ms |
720 KB |
Output is correct |
23 |
Correct |
2 ms |
720 KB |
Output is correct |
24 |
Correct |
3 ms |
720 KB |
Output is correct |
25 |
Correct |
5 ms |
768 KB |
Output is correct |
26 |
Correct |
5 ms |
776 KB |
Output is correct |
27 |
Correct |
5 ms |
776 KB |
Output is correct |
28 |
Correct |
5 ms |
776 KB |
Output is correct |
29 |
Correct |
5 ms |
776 KB |
Output is correct |
30 |
Correct |
3 ms |
776 KB |
Output is correct |
31 |
Correct |
4 ms |
776 KB |
Output is correct |
32 |
Correct |
3 ms |
776 KB |
Output is correct |
33 |
Correct |
5 ms |
776 KB |
Output is correct |
34 |
Correct |
5 ms |
776 KB |
Output is correct |
35 |
Correct |
5 ms |
776 KB |
Output is correct |
36 |
Correct |
3 ms |
776 KB |
Output is correct |
37 |
Correct |
14 ms |
800 KB |
Output is correct |
38 |
Correct |
14 ms |
928 KB |
Output is correct |
39 |
Correct |
49 ms |
1240 KB |
Output is correct |
40 |
Correct |
28 ms |
1240 KB |
Output is correct |
41 |
Correct |
62 ms |
1440 KB |
Output is correct |
42 |
Correct |
26 ms |
1440 KB |
Output is correct |
43 |
Correct |
47 ms |
1440 KB |
Output is correct |
44 |
Correct |
47 ms |
1440 KB |
Output is correct |
45 |
Correct |
45 ms |
1440 KB |
Output is correct |
46 |
Correct |
31 ms |
1440 KB |
Output is correct |
47 |
Correct |
27 ms |
1440 KB |
Output is correct |
48 |
Correct |
51 ms |
1440 KB |
Output is correct |
49 |
Correct |
61 ms |
1440 KB |
Output is correct |
50 |
Correct |
27 ms |
1440 KB |
Output is correct |
51 |
Correct |
4 ms |
1440 KB |
Output is correct |
52 |
Correct |
61 ms |
1440 KB |
Output is correct |
53 |
Correct |
43 ms |
1440 KB |
Output is correct |
54 |
Correct |
64 ms |
1440 KB |
Output is correct |
55 |
Correct |
130 ms |
1952 KB |
Output is correct |
56 |
Correct |
56 ms |
1952 KB |
Output is correct |
57 |
Correct |
126 ms |
1952 KB |
Output is correct |
58 |
Correct |
66 ms |
1952 KB |
Output is correct |
59 |
Correct |
88 ms |
1952 KB |
Output is correct |
60 |
Correct |
9 ms |
1952 KB |
Output is correct |
61 |
Correct |
99 ms |
1952 KB |
Output is correct |
62 |
Correct |
95 ms |
1952 KB |
Output is correct |
63 |
Correct |
105 ms |
1952 KB |
Output is correct |
64 |
Correct |
101 ms |
1952 KB |
Output is correct |
65 |
Correct |
58 ms |
1952 KB |
Output is correct |
66 |
Correct |
58 ms |
1952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
464 KB |
Output is correct |
4 |
Correct |
2 ms |
488 KB |
Output is correct |
5 |
Correct |
2 ms |
668 KB |
Output is correct |
6 |
Correct |
2 ms |
668 KB |
Output is correct |
7 |
Correct |
2 ms |
692 KB |
Output is correct |
8 |
Correct |
2 ms |
720 KB |
Output is correct |
9 |
Correct |
2 ms |
720 KB |
Output is correct |
10 |
Correct |
2 ms |
720 KB |
Output is correct |
11 |
Correct |
2 ms |
720 KB |
Output is correct |
12 |
Correct |
2 ms |
720 KB |
Output is correct |
13 |
Correct |
2 ms |
720 KB |
Output is correct |
14 |
Correct |
2 ms |
720 KB |
Output is correct |
15 |
Correct |
2 ms |
720 KB |
Output is correct |
16 |
Correct |
2 ms |
720 KB |
Output is correct |
17 |
Correct |
2 ms |
720 KB |
Output is correct |
18 |
Correct |
2 ms |
720 KB |
Output is correct |
19 |
Correct |
2 ms |
720 KB |
Output is correct |
20 |
Correct |
2 ms |
720 KB |
Output is correct |
21 |
Correct |
2 ms |
720 KB |
Output is correct |
22 |
Correct |
3 ms |
720 KB |
Output is correct |
23 |
Correct |
2 ms |
720 KB |
Output is correct |
24 |
Correct |
3 ms |
720 KB |
Output is correct |
25 |
Correct |
5 ms |
768 KB |
Output is correct |
26 |
Correct |
5 ms |
776 KB |
Output is correct |
27 |
Correct |
5 ms |
776 KB |
Output is correct |
28 |
Correct |
5 ms |
776 KB |
Output is correct |
29 |
Correct |
5 ms |
776 KB |
Output is correct |
30 |
Correct |
3 ms |
776 KB |
Output is correct |
31 |
Correct |
4 ms |
776 KB |
Output is correct |
32 |
Correct |
3 ms |
776 KB |
Output is correct |
33 |
Correct |
5 ms |
776 KB |
Output is correct |
34 |
Correct |
5 ms |
776 KB |
Output is correct |
35 |
Correct |
5 ms |
776 KB |
Output is correct |
36 |
Correct |
3 ms |
776 KB |
Output is correct |
37 |
Correct |
14 ms |
800 KB |
Output is correct |
38 |
Correct |
14 ms |
928 KB |
Output is correct |
39 |
Correct |
49 ms |
1240 KB |
Output is correct |
40 |
Correct |
28 ms |
1240 KB |
Output is correct |
41 |
Correct |
62 ms |
1440 KB |
Output is correct |
42 |
Correct |
26 ms |
1440 KB |
Output is correct |
43 |
Correct |
47 ms |
1440 KB |
Output is correct |
44 |
Correct |
47 ms |
1440 KB |
Output is correct |
45 |
Correct |
45 ms |
1440 KB |
Output is correct |
46 |
Correct |
31 ms |
1440 KB |
Output is correct |
47 |
Correct |
27 ms |
1440 KB |
Output is correct |
48 |
Correct |
51 ms |
1440 KB |
Output is correct |
49 |
Correct |
61 ms |
1440 KB |
Output is correct |
50 |
Correct |
27 ms |
1440 KB |
Output is correct |
51 |
Correct |
4 ms |
1440 KB |
Output is correct |
52 |
Correct |
61 ms |
1440 KB |
Output is correct |
53 |
Correct |
43 ms |
1440 KB |
Output is correct |
54 |
Correct |
64 ms |
1440 KB |
Output is correct |
55 |
Correct |
130 ms |
1952 KB |
Output is correct |
56 |
Correct |
56 ms |
1952 KB |
Output is correct |
57 |
Correct |
126 ms |
1952 KB |
Output is correct |
58 |
Correct |
66 ms |
1952 KB |
Output is correct |
59 |
Correct |
88 ms |
1952 KB |
Output is correct |
60 |
Correct |
9 ms |
1952 KB |
Output is correct |
61 |
Correct |
99 ms |
1952 KB |
Output is correct |
62 |
Correct |
95 ms |
1952 KB |
Output is correct |
63 |
Correct |
105 ms |
1952 KB |
Output is correct |
64 |
Correct |
101 ms |
1952 KB |
Output is correct |
65 |
Correct |
58 ms |
1952 KB |
Output is correct |
66 |
Correct |
58 ms |
1952 KB |
Output is correct |
67 |
Correct |
101 ms |
1952 KB |
Output is correct |
68 |
Correct |
23 ms |
1952 KB |
Output is correct |
69 |
Correct |
324 ms |
3080 KB |
Output is correct |
70 |
Correct |
211 ms |
3080 KB |
Output is correct |
71 |
Correct |
188 ms |
3080 KB |
Output is correct |
72 |
Correct |
190 ms |
3080 KB |
Output is correct |
73 |
Correct |
184 ms |
3080 KB |
Output is correct |
74 |
Correct |
364 ms |
3364 KB |
Output is correct |
75 |
Correct |
275 ms |
3364 KB |
Output is correct |
76 |
Correct |
392 ms |
3488 KB |
Output is correct |
77 |
Correct |
360 ms |
3504 KB |
Output is correct |