#include<bits/stdc++.h>
using namespace std;
int sum=0;
int c[250001], res[250001];
void add(int t){
sum+=t;
for(int i=sum; i>=t; i--){
c[i]+=c[i-t];
}
}
void del(int t){
for(int i=t; i<=sum; i++){
c[i]-=c[i-t];
}
sum-=t;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
memset(c, 0, sizeof c);
memset(res, 0, sizeof res);
c[0]=1;
int n;
cin >> n;
int a[n];
for(int i=0; i<n; i++) {
cin >> a[i];
add(a[i]);
}
if(sum%2 || !c[sum/2]) return cout << 0, 0;
for(int i=0; i<n; i++){
del(a[i]);
for(int j=1; j<=sum; j++){
if((sum+j)%2) continue;
if(c[(sum+j)/2]) res[j]++;
}
add(a[i]);
}
vector<int> ans;
for(int i=1; i<=sum; i++){
if(res[i]==n) ans.push_back(i);
}
cout << ans.size() << endl;
for(int i=0; i<ans.size(); i++) cout << ans[i] << " ";
return 0;
}
Compilation message
bootfall.cpp: In function 'int main()':
bootfall.cpp:49:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<ans.size(); i++) cout << ans[i] << " ";
~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2296 KB |
Output is correct |
2 |
Correct |
4 ms |
2296 KB |
Output is correct |
3 |
Correct |
3 ms |
2352 KB |
Output is correct |
4 |
Correct |
5 ms |
2484 KB |
Output is correct |
5 |
Correct |
4 ms |
2540 KB |
Output is correct |
6 |
Correct |
4 ms |
2540 KB |
Output is correct |
7 |
Correct |
4 ms |
2540 KB |
Output is correct |
8 |
Correct |
5 ms |
2540 KB |
Output is correct |
9 |
Correct |
3 ms |
2540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2296 KB |
Output is correct |
2 |
Correct |
4 ms |
2296 KB |
Output is correct |
3 |
Correct |
3 ms |
2352 KB |
Output is correct |
4 |
Correct |
5 ms |
2484 KB |
Output is correct |
5 |
Correct |
4 ms |
2540 KB |
Output is correct |
6 |
Correct |
4 ms |
2540 KB |
Output is correct |
7 |
Correct |
4 ms |
2540 KB |
Output is correct |
8 |
Correct |
5 ms |
2540 KB |
Output is correct |
9 |
Correct |
3 ms |
2540 KB |
Output is correct |
10 |
Correct |
5 ms |
2540 KB |
Output is correct |
11 |
Correct |
5 ms |
2540 KB |
Output is correct |
12 |
Correct |
5 ms |
2540 KB |
Output is correct |
13 |
Correct |
5 ms |
2540 KB |
Output is correct |
14 |
Correct |
4 ms |
2540 KB |
Output is correct |
15 |
Correct |
4 ms |
2540 KB |
Output is correct |
16 |
Correct |
3 ms |
2540 KB |
Output is correct |
17 |
Correct |
5 ms |
2544 KB |
Output is correct |
18 |
Correct |
5 ms |
2544 KB |
Output is correct |
19 |
Correct |
6 ms |
2580 KB |
Output is correct |
20 |
Correct |
4 ms |
2580 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2296 KB |
Output is correct |
2 |
Correct |
4 ms |
2296 KB |
Output is correct |
3 |
Correct |
3 ms |
2352 KB |
Output is correct |
4 |
Correct |
5 ms |
2484 KB |
Output is correct |
5 |
Correct |
4 ms |
2540 KB |
Output is correct |
6 |
Correct |
4 ms |
2540 KB |
Output is correct |
7 |
Correct |
4 ms |
2540 KB |
Output is correct |
8 |
Correct |
5 ms |
2540 KB |
Output is correct |
9 |
Correct |
3 ms |
2540 KB |
Output is correct |
10 |
Correct |
5 ms |
2540 KB |
Output is correct |
11 |
Correct |
5 ms |
2540 KB |
Output is correct |
12 |
Correct |
5 ms |
2540 KB |
Output is correct |
13 |
Correct |
5 ms |
2540 KB |
Output is correct |
14 |
Correct |
4 ms |
2540 KB |
Output is correct |
15 |
Correct |
4 ms |
2540 KB |
Output is correct |
16 |
Correct |
3 ms |
2540 KB |
Output is correct |
17 |
Correct |
5 ms |
2544 KB |
Output is correct |
18 |
Correct |
5 ms |
2544 KB |
Output is correct |
19 |
Correct |
6 ms |
2580 KB |
Output is correct |
20 |
Correct |
4 ms |
2580 KB |
Output is correct |
21 |
Correct |
5 ms |
2580 KB |
Output is correct |
22 |
Correct |
6 ms |
2580 KB |
Output is correct |
23 |
Correct |
5 ms |
2580 KB |
Output is correct |
24 |
Correct |
6 ms |
2620 KB |
Output is correct |
25 |
Correct |
9 ms |
2620 KB |
Output is correct |
26 |
Correct |
11 ms |
2636 KB |
Output is correct |
27 |
Correct |
10 ms |
2636 KB |
Output is correct |
28 |
Correct |
9 ms |
2636 KB |
Output is correct |
29 |
Correct |
10 ms |
2636 KB |
Output is correct |
30 |
Correct |
7 ms |
2636 KB |
Output is correct |
31 |
Correct |
7 ms |
2636 KB |
Output is correct |
32 |
Correct |
7 ms |
2660 KB |
Output is correct |
33 |
Correct |
9 ms |
2660 KB |
Output is correct |
34 |
Correct |
7 ms |
2660 KB |
Output is correct |
35 |
Correct |
9 ms |
2660 KB |
Output is correct |
36 |
Correct |
8 ms |
2732 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2296 KB |
Output is correct |
2 |
Correct |
4 ms |
2296 KB |
Output is correct |
3 |
Correct |
3 ms |
2352 KB |
Output is correct |
4 |
Correct |
5 ms |
2484 KB |
Output is correct |
5 |
Correct |
4 ms |
2540 KB |
Output is correct |
6 |
Correct |
4 ms |
2540 KB |
Output is correct |
7 |
Correct |
4 ms |
2540 KB |
Output is correct |
8 |
Correct |
5 ms |
2540 KB |
Output is correct |
9 |
Correct |
3 ms |
2540 KB |
Output is correct |
10 |
Correct |
5 ms |
2540 KB |
Output is correct |
11 |
Correct |
5 ms |
2540 KB |
Output is correct |
12 |
Correct |
5 ms |
2540 KB |
Output is correct |
13 |
Correct |
5 ms |
2540 KB |
Output is correct |
14 |
Correct |
4 ms |
2540 KB |
Output is correct |
15 |
Correct |
4 ms |
2540 KB |
Output is correct |
16 |
Correct |
3 ms |
2540 KB |
Output is correct |
17 |
Correct |
5 ms |
2544 KB |
Output is correct |
18 |
Correct |
5 ms |
2544 KB |
Output is correct |
19 |
Correct |
6 ms |
2580 KB |
Output is correct |
20 |
Correct |
4 ms |
2580 KB |
Output is correct |
21 |
Correct |
5 ms |
2580 KB |
Output is correct |
22 |
Correct |
6 ms |
2580 KB |
Output is correct |
23 |
Correct |
5 ms |
2580 KB |
Output is correct |
24 |
Correct |
6 ms |
2620 KB |
Output is correct |
25 |
Correct |
9 ms |
2620 KB |
Output is correct |
26 |
Correct |
11 ms |
2636 KB |
Output is correct |
27 |
Correct |
10 ms |
2636 KB |
Output is correct |
28 |
Correct |
9 ms |
2636 KB |
Output is correct |
29 |
Correct |
10 ms |
2636 KB |
Output is correct |
30 |
Correct |
7 ms |
2636 KB |
Output is correct |
31 |
Correct |
7 ms |
2636 KB |
Output is correct |
32 |
Correct |
7 ms |
2660 KB |
Output is correct |
33 |
Correct |
9 ms |
2660 KB |
Output is correct |
34 |
Correct |
7 ms |
2660 KB |
Output is correct |
35 |
Correct |
9 ms |
2660 KB |
Output is correct |
36 |
Correct |
8 ms |
2732 KB |
Output is correct |
37 |
Correct |
27 ms |
2776 KB |
Output is correct |
38 |
Correct |
18 ms |
2788 KB |
Output is correct |
39 |
Correct |
72 ms |
2788 KB |
Output is correct |
40 |
Correct |
33 ms |
2920 KB |
Output is correct |
41 |
Correct |
67 ms |
2920 KB |
Output is correct |
42 |
Correct |
42 ms |
2956 KB |
Output is correct |
43 |
Correct |
76 ms |
3088 KB |
Output is correct |
44 |
Correct |
85 ms |
3132 KB |
Output is correct |
45 |
Correct |
66 ms |
3144 KB |
Output is correct |
46 |
Correct |
30 ms |
3144 KB |
Output is correct |
47 |
Correct |
38 ms |
3144 KB |
Output is correct |
48 |
Correct |
58 ms |
3144 KB |
Output is correct |
49 |
Correct |
50 ms |
3144 KB |
Output is correct |
50 |
Correct |
32 ms |
3144 KB |
Output is correct |
51 |
Correct |
8 ms |
3144 KB |
Output is correct |
52 |
Correct |
67 ms |
3156 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2296 KB |
Output is correct |
2 |
Correct |
4 ms |
2296 KB |
Output is correct |
3 |
Correct |
3 ms |
2352 KB |
Output is correct |
4 |
Correct |
5 ms |
2484 KB |
Output is correct |
5 |
Correct |
4 ms |
2540 KB |
Output is correct |
6 |
Correct |
4 ms |
2540 KB |
Output is correct |
7 |
Correct |
4 ms |
2540 KB |
Output is correct |
8 |
Correct |
5 ms |
2540 KB |
Output is correct |
9 |
Correct |
3 ms |
2540 KB |
Output is correct |
10 |
Correct |
5 ms |
2540 KB |
Output is correct |
11 |
Correct |
5 ms |
2540 KB |
Output is correct |
12 |
Correct |
5 ms |
2540 KB |
Output is correct |
13 |
Correct |
5 ms |
2540 KB |
Output is correct |
14 |
Correct |
4 ms |
2540 KB |
Output is correct |
15 |
Correct |
4 ms |
2540 KB |
Output is correct |
16 |
Correct |
3 ms |
2540 KB |
Output is correct |
17 |
Correct |
5 ms |
2544 KB |
Output is correct |
18 |
Correct |
5 ms |
2544 KB |
Output is correct |
19 |
Correct |
6 ms |
2580 KB |
Output is correct |
20 |
Correct |
4 ms |
2580 KB |
Output is correct |
21 |
Correct |
5 ms |
2580 KB |
Output is correct |
22 |
Correct |
6 ms |
2580 KB |
Output is correct |
23 |
Correct |
5 ms |
2580 KB |
Output is correct |
24 |
Correct |
6 ms |
2620 KB |
Output is correct |
25 |
Correct |
9 ms |
2620 KB |
Output is correct |
26 |
Correct |
11 ms |
2636 KB |
Output is correct |
27 |
Correct |
10 ms |
2636 KB |
Output is correct |
28 |
Correct |
9 ms |
2636 KB |
Output is correct |
29 |
Correct |
10 ms |
2636 KB |
Output is correct |
30 |
Correct |
7 ms |
2636 KB |
Output is correct |
31 |
Correct |
7 ms |
2636 KB |
Output is correct |
32 |
Correct |
7 ms |
2660 KB |
Output is correct |
33 |
Correct |
9 ms |
2660 KB |
Output is correct |
34 |
Correct |
7 ms |
2660 KB |
Output is correct |
35 |
Correct |
9 ms |
2660 KB |
Output is correct |
36 |
Correct |
8 ms |
2732 KB |
Output is correct |
37 |
Correct |
27 ms |
2776 KB |
Output is correct |
38 |
Correct |
18 ms |
2788 KB |
Output is correct |
39 |
Correct |
72 ms |
2788 KB |
Output is correct |
40 |
Correct |
33 ms |
2920 KB |
Output is correct |
41 |
Correct |
67 ms |
2920 KB |
Output is correct |
42 |
Correct |
42 ms |
2956 KB |
Output is correct |
43 |
Correct |
76 ms |
3088 KB |
Output is correct |
44 |
Correct |
85 ms |
3132 KB |
Output is correct |
45 |
Correct |
66 ms |
3144 KB |
Output is correct |
46 |
Correct |
30 ms |
3144 KB |
Output is correct |
47 |
Correct |
38 ms |
3144 KB |
Output is correct |
48 |
Correct |
58 ms |
3144 KB |
Output is correct |
49 |
Correct |
50 ms |
3144 KB |
Output is correct |
50 |
Correct |
32 ms |
3144 KB |
Output is correct |
51 |
Correct |
8 ms |
3144 KB |
Output is correct |
52 |
Correct |
67 ms |
3156 KB |
Output is correct |
53 |
Correct |
79 ms |
3156 KB |
Output is correct |
54 |
Correct |
96 ms |
3236 KB |
Output is correct |
55 |
Correct |
129 ms |
3456 KB |
Output is correct |
56 |
Correct |
90 ms |
3456 KB |
Output is correct |
57 |
Correct |
142 ms |
3508 KB |
Output is correct |
58 |
Correct |
102 ms |
3508 KB |
Output is correct |
59 |
Correct |
107 ms |
3508 KB |
Output is correct |
60 |
Correct |
11 ms |
3508 KB |
Output is correct |
61 |
Correct |
113 ms |
3508 KB |
Output is correct |
62 |
Correct |
129 ms |
3508 KB |
Output is correct |
63 |
Correct |
122 ms |
3508 KB |
Output is correct |
64 |
Correct |
114 ms |
3508 KB |
Output is correct |
65 |
Correct |
65 ms |
3508 KB |
Output is correct |
66 |
Correct |
89 ms |
3508 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2296 KB |
Output is correct |
2 |
Correct |
4 ms |
2296 KB |
Output is correct |
3 |
Correct |
3 ms |
2352 KB |
Output is correct |
4 |
Correct |
5 ms |
2484 KB |
Output is correct |
5 |
Correct |
4 ms |
2540 KB |
Output is correct |
6 |
Correct |
4 ms |
2540 KB |
Output is correct |
7 |
Correct |
4 ms |
2540 KB |
Output is correct |
8 |
Correct |
5 ms |
2540 KB |
Output is correct |
9 |
Correct |
3 ms |
2540 KB |
Output is correct |
10 |
Correct |
5 ms |
2540 KB |
Output is correct |
11 |
Correct |
5 ms |
2540 KB |
Output is correct |
12 |
Correct |
5 ms |
2540 KB |
Output is correct |
13 |
Correct |
5 ms |
2540 KB |
Output is correct |
14 |
Correct |
4 ms |
2540 KB |
Output is correct |
15 |
Correct |
4 ms |
2540 KB |
Output is correct |
16 |
Correct |
3 ms |
2540 KB |
Output is correct |
17 |
Correct |
5 ms |
2544 KB |
Output is correct |
18 |
Correct |
5 ms |
2544 KB |
Output is correct |
19 |
Correct |
6 ms |
2580 KB |
Output is correct |
20 |
Correct |
4 ms |
2580 KB |
Output is correct |
21 |
Correct |
5 ms |
2580 KB |
Output is correct |
22 |
Correct |
6 ms |
2580 KB |
Output is correct |
23 |
Correct |
5 ms |
2580 KB |
Output is correct |
24 |
Correct |
6 ms |
2620 KB |
Output is correct |
25 |
Correct |
9 ms |
2620 KB |
Output is correct |
26 |
Correct |
11 ms |
2636 KB |
Output is correct |
27 |
Correct |
10 ms |
2636 KB |
Output is correct |
28 |
Correct |
9 ms |
2636 KB |
Output is correct |
29 |
Correct |
10 ms |
2636 KB |
Output is correct |
30 |
Correct |
7 ms |
2636 KB |
Output is correct |
31 |
Correct |
7 ms |
2636 KB |
Output is correct |
32 |
Correct |
7 ms |
2660 KB |
Output is correct |
33 |
Correct |
9 ms |
2660 KB |
Output is correct |
34 |
Correct |
7 ms |
2660 KB |
Output is correct |
35 |
Correct |
9 ms |
2660 KB |
Output is correct |
36 |
Correct |
8 ms |
2732 KB |
Output is correct |
37 |
Correct |
27 ms |
2776 KB |
Output is correct |
38 |
Correct |
18 ms |
2788 KB |
Output is correct |
39 |
Correct |
72 ms |
2788 KB |
Output is correct |
40 |
Correct |
33 ms |
2920 KB |
Output is correct |
41 |
Correct |
67 ms |
2920 KB |
Output is correct |
42 |
Correct |
42 ms |
2956 KB |
Output is correct |
43 |
Correct |
76 ms |
3088 KB |
Output is correct |
44 |
Correct |
85 ms |
3132 KB |
Output is correct |
45 |
Correct |
66 ms |
3144 KB |
Output is correct |
46 |
Correct |
30 ms |
3144 KB |
Output is correct |
47 |
Correct |
38 ms |
3144 KB |
Output is correct |
48 |
Correct |
58 ms |
3144 KB |
Output is correct |
49 |
Correct |
50 ms |
3144 KB |
Output is correct |
50 |
Correct |
32 ms |
3144 KB |
Output is correct |
51 |
Correct |
8 ms |
3144 KB |
Output is correct |
52 |
Correct |
67 ms |
3156 KB |
Output is correct |
53 |
Correct |
79 ms |
3156 KB |
Output is correct |
54 |
Correct |
96 ms |
3236 KB |
Output is correct |
55 |
Correct |
129 ms |
3456 KB |
Output is correct |
56 |
Correct |
90 ms |
3456 KB |
Output is correct |
57 |
Correct |
142 ms |
3508 KB |
Output is correct |
58 |
Correct |
102 ms |
3508 KB |
Output is correct |
59 |
Correct |
107 ms |
3508 KB |
Output is correct |
60 |
Correct |
11 ms |
3508 KB |
Output is correct |
61 |
Correct |
113 ms |
3508 KB |
Output is correct |
62 |
Correct |
129 ms |
3508 KB |
Output is correct |
63 |
Correct |
122 ms |
3508 KB |
Output is correct |
64 |
Correct |
114 ms |
3508 KB |
Output is correct |
65 |
Correct |
65 ms |
3508 KB |
Output is correct |
66 |
Correct |
89 ms |
3508 KB |
Output is correct |
67 |
Correct |
117 ms |
3508 KB |
Output is correct |
68 |
Correct |
42 ms |
3508 KB |
Output is correct |
69 |
Correct |
363 ms |
4288 KB |
Output is correct |
70 |
Correct |
215 ms |
4288 KB |
Output is correct |
71 |
Correct |
197 ms |
4288 KB |
Output is correct |
72 |
Correct |
220 ms |
4288 KB |
Output is correct |
73 |
Correct |
287 ms |
4288 KB |
Output is correct |
74 |
Correct |
425 ms |
4288 KB |
Output is correct |
75 |
Correct |
302 ms |
4288 KB |
Output is correct |
76 |
Correct |
514 ms |
4288 KB |
Output is correct |
77 |
Correct |
445 ms |
4288 KB |
Output is correct |