#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ar array
#define fr first
#define sc second
#define vec vector
#define ret return
#define ins insert
#define mk make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_back
#define int long long
#define pii pair<int,int>
#define all(s) s.begin(), s.end()
#define allr(s) s.rbegin(), s.rend()
#define NeedForSpeed ios::sync_with_stdio(0),cin.tie(0);
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const int N=1e6+12,INF=1e9,mod = 1e9+7;
bool iswowel(char n){ n = toupper(n); if(n == 'A' || n == 'O' || n == 'U' || n == 'E' || n == 'I') return true; else return false;}
int n,m,k,x,y,l,r,o,ans,res,ok,mx,mn = INF;
int a[N],b[N],dp[N],c;
set<int>s;
void add(int v){
for(int i=res; i>=0; i--)dp[i + v] += dp[i];
res += v;
}
void del(int v){
res -= v;
for(int i=0; i<=res; ++i)dp[i + v] -= dp[i];
}
main(){
NeedForSpeed
cin>>n;
dp[0] = 1;
for(int i=0; i<n; i++){
cin>>a[i];
add(a[i]);
ans += a[i];
}
if((ans) % 2 || !dp[(ans)/2]){
cout<<0<<endl;
ret 0;
}
for(int i=0; i<n; i++){
del(a[i]);
for(int j=1; j<=ans; j++){
if((res+j) % 2 || !dp[(res+j)/2])b[j] = 1;
}
add(a[i]);
}
for(int i=1; i<=ans; i++)if(!b[i])s.ins(i);
cout<<s.size()<<endl;
for(int i : s)cout<<i<<" ";
return 0;
}
Compilation message
bootfall.cpp:44:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
44 | main(){
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
0 ms |
304 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
0 ms |
304 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
324 KB |
Output is correct |
13 |
Correct |
1 ms |
324 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
320 KB |
Output is correct |
16 |
Correct |
0 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
0 ms |
304 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
324 KB |
Output is correct |
13 |
Correct |
1 ms |
324 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
320 KB |
Output is correct |
16 |
Correct |
0 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
324 KB |
Output is correct |
21 |
Correct |
1 ms |
460 KB |
Output is correct |
22 |
Correct |
2 ms |
428 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
3 ms |
448 KB |
Output is correct |
25 |
Correct |
6 ms |
588 KB |
Output is correct |
26 |
Correct |
4 ms |
588 KB |
Output is correct |
27 |
Correct |
3 ms |
576 KB |
Output is correct |
28 |
Correct |
3 ms |
460 KB |
Output is correct |
29 |
Correct |
4 ms |
460 KB |
Output is correct |
30 |
Correct |
2 ms |
332 KB |
Output is correct |
31 |
Correct |
4 ms |
588 KB |
Output is correct |
32 |
Correct |
2 ms |
460 KB |
Output is correct |
33 |
Correct |
4 ms |
460 KB |
Output is correct |
34 |
Correct |
4 ms |
480 KB |
Output is correct |
35 |
Correct |
5 ms |
460 KB |
Output is correct |
36 |
Correct |
4 ms |
460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
0 ms |
304 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
324 KB |
Output is correct |
13 |
Correct |
1 ms |
324 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
320 KB |
Output is correct |
16 |
Correct |
0 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
324 KB |
Output is correct |
21 |
Correct |
1 ms |
460 KB |
Output is correct |
22 |
Correct |
2 ms |
428 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
3 ms |
448 KB |
Output is correct |
25 |
Correct |
6 ms |
588 KB |
Output is correct |
26 |
Correct |
4 ms |
588 KB |
Output is correct |
27 |
Correct |
3 ms |
576 KB |
Output is correct |
28 |
Correct |
3 ms |
460 KB |
Output is correct |
29 |
Correct |
4 ms |
460 KB |
Output is correct |
30 |
Correct |
2 ms |
332 KB |
Output is correct |
31 |
Correct |
4 ms |
588 KB |
Output is correct |
32 |
Correct |
2 ms |
460 KB |
Output is correct |
33 |
Correct |
4 ms |
460 KB |
Output is correct |
34 |
Correct |
4 ms |
480 KB |
Output is correct |
35 |
Correct |
5 ms |
460 KB |
Output is correct |
36 |
Correct |
4 ms |
460 KB |
Output is correct |
37 |
Correct |
16 ms |
1100 KB |
Output is correct |
38 |
Correct |
16 ms |
1168 KB |
Output is correct |
39 |
Correct |
40 ms |
1228 KB |
Output is correct |
40 |
Correct |
24 ms |
1604 KB |
Output is correct |
41 |
Correct |
52 ms |
1484 KB |
Output is correct |
42 |
Correct |
23 ms |
1528 KB |
Output is correct |
43 |
Correct |
38 ms |
2464 KB |
Output is correct |
44 |
Correct |
39 ms |
2500 KB |
Output is correct |
45 |
Correct |
40 ms |
2516 KB |
Output is correct |
46 |
Correct |
20 ms |
716 KB |
Output is correct |
47 |
Correct |
23 ms |
1664 KB |
Output is correct |
48 |
Correct |
41 ms |
2192 KB |
Output is correct |
49 |
Correct |
51 ms |
1476 KB |
Output is correct |
50 |
Correct |
23 ms |
1620 KB |
Output is correct |
51 |
Correct |
2 ms |
584 KB |
Output is correct |
52 |
Correct |
51 ms |
2964 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
0 ms |
304 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
324 KB |
Output is correct |
13 |
Correct |
1 ms |
324 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
320 KB |
Output is correct |
16 |
Correct |
0 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
324 KB |
Output is correct |
21 |
Correct |
1 ms |
460 KB |
Output is correct |
22 |
Correct |
2 ms |
428 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
3 ms |
448 KB |
Output is correct |
25 |
Correct |
6 ms |
588 KB |
Output is correct |
26 |
Correct |
4 ms |
588 KB |
Output is correct |
27 |
Correct |
3 ms |
576 KB |
Output is correct |
28 |
Correct |
3 ms |
460 KB |
Output is correct |
29 |
Correct |
4 ms |
460 KB |
Output is correct |
30 |
Correct |
2 ms |
332 KB |
Output is correct |
31 |
Correct |
4 ms |
588 KB |
Output is correct |
32 |
Correct |
2 ms |
460 KB |
Output is correct |
33 |
Correct |
4 ms |
460 KB |
Output is correct |
34 |
Correct |
4 ms |
480 KB |
Output is correct |
35 |
Correct |
5 ms |
460 KB |
Output is correct |
36 |
Correct |
4 ms |
460 KB |
Output is correct |
37 |
Correct |
16 ms |
1100 KB |
Output is correct |
38 |
Correct |
16 ms |
1168 KB |
Output is correct |
39 |
Correct |
40 ms |
1228 KB |
Output is correct |
40 |
Correct |
24 ms |
1604 KB |
Output is correct |
41 |
Correct |
52 ms |
1484 KB |
Output is correct |
42 |
Correct |
23 ms |
1528 KB |
Output is correct |
43 |
Correct |
38 ms |
2464 KB |
Output is correct |
44 |
Correct |
39 ms |
2500 KB |
Output is correct |
45 |
Correct |
40 ms |
2516 KB |
Output is correct |
46 |
Correct |
20 ms |
716 KB |
Output is correct |
47 |
Correct |
23 ms |
1664 KB |
Output is correct |
48 |
Correct |
41 ms |
2192 KB |
Output is correct |
49 |
Correct |
51 ms |
1476 KB |
Output is correct |
50 |
Correct |
23 ms |
1620 KB |
Output is correct |
51 |
Correct |
2 ms |
584 KB |
Output is correct |
52 |
Correct |
51 ms |
2964 KB |
Output is correct |
53 |
Correct |
51 ms |
2192 KB |
Output is correct |
54 |
Correct |
57 ms |
2604 KB |
Output is correct |
55 |
Correct |
101 ms |
4540 KB |
Output is correct |
56 |
Correct |
64 ms |
2580 KB |
Output is correct |
57 |
Correct |
113 ms |
4932 KB |
Output is correct |
58 |
Correct |
65 ms |
2828 KB |
Output is correct |
59 |
Correct |
82 ms |
3440 KB |
Output is correct |
60 |
Correct |
6 ms |
716 KB |
Output is correct |
61 |
Correct |
89 ms |
3840 KB |
Output is correct |
62 |
Correct |
105 ms |
4256 KB |
Output is correct |
63 |
Correct |
129 ms |
4380 KB |
Output is correct |
64 |
Correct |
85 ms |
4364 KB |
Output is correct |
65 |
Correct |
37 ms |
1088 KB |
Output is correct |
66 |
Correct |
41 ms |
1416 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
0 ms |
304 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
324 KB |
Output is correct |
13 |
Correct |
1 ms |
324 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
320 KB |
Output is correct |
16 |
Correct |
0 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
324 KB |
Output is correct |
21 |
Correct |
1 ms |
460 KB |
Output is correct |
22 |
Correct |
2 ms |
428 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
3 ms |
448 KB |
Output is correct |
25 |
Correct |
6 ms |
588 KB |
Output is correct |
26 |
Correct |
4 ms |
588 KB |
Output is correct |
27 |
Correct |
3 ms |
576 KB |
Output is correct |
28 |
Correct |
3 ms |
460 KB |
Output is correct |
29 |
Correct |
4 ms |
460 KB |
Output is correct |
30 |
Correct |
2 ms |
332 KB |
Output is correct |
31 |
Correct |
4 ms |
588 KB |
Output is correct |
32 |
Correct |
2 ms |
460 KB |
Output is correct |
33 |
Correct |
4 ms |
460 KB |
Output is correct |
34 |
Correct |
4 ms |
480 KB |
Output is correct |
35 |
Correct |
5 ms |
460 KB |
Output is correct |
36 |
Correct |
4 ms |
460 KB |
Output is correct |
37 |
Correct |
16 ms |
1100 KB |
Output is correct |
38 |
Correct |
16 ms |
1168 KB |
Output is correct |
39 |
Correct |
40 ms |
1228 KB |
Output is correct |
40 |
Correct |
24 ms |
1604 KB |
Output is correct |
41 |
Correct |
52 ms |
1484 KB |
Output is correct |
42 |
Correct |
23 ms |
1528 KB |
Output is correct |
43 |
Correct |
38 ms |
2464 KB |
Output is correct |
44 |
Correct |
39 ms |
2500 KB |
Output is correct |
45 |
Correct |
40 ms |
2516 KB |
Output is correct |
46 |
Correct |
20 ms |
716 KB |
Output is correct |
47 |
Correct |
23 ms |
1664 KB |
Output is correct |
48 |
Correct |
41 ms |
2192 KB |
Output is correct |
49 |
Correct |
51 ms |
1476 KB |
Output is correct |
50 |
Correct |
23 ms |
1620 KB |
Output is correct |
51 |
Correct |
2 ms |
584 KB |
Output is correct |
52 |
Correct |
51 ms |
2964 KB |
Output is correct |
53 |
Correct |
51 ms |
2192 KB |
Output is correct |
54 |
Correct |
57 ms |
2604 KB |
Output is correct |
55 |
Correct |
101 ms |
4540 KB |
Output is correct |
56 |
Correct |
64 ms |
2580 KB |
Output is correct |
57 |
Correct |
113 ms |
4932 KB |
Output is correct |
58 |
Correct |
65 ms |
2828 KB |
Output is correct |
59 |
Correct |
82 ms |
3440 KB |
Output is correct |
60 |
Correct |
6 ms |
716 KB |
Output is correct |
61 |
Correct |
89 ms |
3840 KB |
Output is correct |
62 |
Correct |
105 ms |
4256 KB |
Output is correct |
63 |
Correct |
129 ms |
4380 KB |
Output is correct |
64 |
Correct |
85 ms |
4364 KB |
Output is correct |
65 |
Correct |
37 ms |
1088 KB |
Output is correct |
66 |
Correct |
41 ms |
1416 KB |
Output is correct |
67 |
Correct |
89 ms |
3628 KB |
Output is correct |
68 |
Correct |
17 ms |
1224 KB |
Output is correct |
69 |
Correct |
268 ms |
8892 KB |
Output is correct |
70 |
Correct |
163 ms |
5656 KB |
Output is correct |
71 |
Correct |
165 ms |
5472 KB |
Output is correct |
72 |
Correct |
160 ms |
2288 KB |
Output is correct |
73 |
Correct |
138 ms |
2284 KB |
Output is correct |
74 |
Correct |
298 ms |
9636 KB |
Output is correct |
75 |
Correct |
216 ms |
7532 KB |
Output is correct |
76 |
Correct |
326 ms |
9528 KB |
Output is correct |
77 |
Correct |
313 ms |
9932 KB |
Output is correct |