#include <bits/stdc++.h>
using namespace std;
int i, j, n, s, a[501], f[250001], ans[250001], Ans, t;
int main(){
cin>>n;f[0]=1;ans[0]=n+1;
for (i=1; i<=n; i++){
cin>>a[i];
for (j=s; j>=0; j--)f[j+a[i]]+=f[j]; s+=a[i];
}
for (i=1; i<=n; i++){
s-=a[i];
for (j=0; j<=s; j++)f[j+a[i]]-=f[j],ans[max(j+j-s,0)]+=(!!f[j]),Ans+=(ans[max(j+j-s,0)]==n);
for (j=s; j>=0; j--)f[j+a[i]]+=f[j];s+=a[i];
}
if(s&1||!f[s/2]){cout<<0;return 0;}
cout<<Ans<<'\n';
for (i=1; i<=s; i++)if(ans[i]==n)cout<<i<<" ";
}
Compilation message
bootfall.cpp: In function 'int main()':
bootfall.cpp:8:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
8 | for (j=s; j>=0; j--)f[j+a[i]]+=f[j]; s+=a[i];
| ^~~
bootfall.cpp:8:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
8 | for (j=s; j>=0; j--)f[j+a[i]]+=f[j]; s+=a[i];
| ^
bootfall.cpp:13:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
13 | for (j=s; j>=0; j--)f[j+a[i]]+=f[j];s+=a[i];
| ^~~
bootfall.cpp:13:39: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
13 | for (j=s; j>=0; j--)f[j+a[i]]+=f[j];s+=a[i];
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
0 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
0 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
2 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
364 KB |
Output is correct |
24 |
Correct |
3 ms |
364 KB |
Output is correct |
25 |
Correct |
4 ms |
364 KB |
Output is correct |
26 |
Correct |
4 ms |
364 KB |
Output is correct |
27 |
Correct |
4 ms |
364 KB |
Output is correct |
28 |
Correct |
4 ms |
364 KB |
Output is correct |
29 |
Correct |
4 ms |
364 KB |
Output is correct |
30 |
Correct |
2 ms |
364 KB |
Output is correct |
31 |
Correct |
4 ms |
364 KB |
Output is correct |
32 |
Correct |
2 ms |
364 KB |
Output is correct |
33 |
Correct |
4 ms |
364 KB |
Output is correct |
34 |
Correct |
4 ms |
364 KB |
Output is correct |
35 |
Correct |
4 ms |
364 KB |
Output is correct |
36 |
Correct |
2 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
0 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
2 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
364 KB |
Output is correct |
24 |
Correct |
3 ms |
364 KB |
Output is correct |
25 |
Correct |
4 ms |
364 KB |
Output is correct |
26 |
Correct |
4 ms |
364 KB |
Output is correct |
27 |
Correct |
4 ms |
364 KB |
Output is correct |
28 |
Correct |
4 ms |
364 KB |
Output is correct |
29 |
Correct |
4 ms |
364 KB |
Output is correct |
30 |
Correct |
2 ms |
364 KB |
Output is correct |
31 |
Correct |
4 ms |
364 KB |
Output is correct |
32 |
Correct |
2 ms |
364 KB |
Output is correct |
33 |
Correct |
4 ms |
364 KB |
Output is correct |
34 |
Correct |
4 ms |
364 KB |
Output is correct |
35 |
Correct |
4 ms |
364 KB |
Output is correct |
36 |
Correct |
2 ms |
364 KB |
Output is correct |
37 |
Correct |
14 ms |
492 KB |
Output is correct |
38 |
Correct |
15 ms |
492 KB |
Output is correct |
39 |
Correct |
51 ms |
748 KB |
Output is correct |
40 |
Correct |
38 ms |
620 KB |
Output is correct |
41 |
Correct |
67 ms |
1004 KB |
Output is correct |
42 |
Correct |
27 ms |
640 KB |
Output is correct |
43 |
Correct |
53 ms |
876 KB |
Output is correct |
44 |
Correct |
50 ms |
876 KB |
Output is correct |
45 |
Correct |
50 ms |
876 KB |
Output is correct |
46 |
Correct |
28 ms |
620 KB |
Output is correct |
47 |
Correct |
29 ms |
620 KB |
Output is correct |
48 |
Correct |
53 ms |
876 KB |
Output is correct |
49 |
Correct |
51 ms |
876 KB |
Output is correct |
50 |
Correct |
29 ms |
640 KB |
Output is correct |
51 |
Correct |
26 ms |
620 KB |
Output is correct |
52 |
Correct |
66 ms |
1004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
0 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
2 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
364 KB |
Output is correct |
24 |
Correct |
3 ms |
364 KB |
Output is correct |
25 |
Correct |
4 ms |
364 KB |
Output is correct |
26 |
Correct |
4 ms |
364 KB |
Output is correct |
27 |
Correct |
4 ms |
364 KB |
Output is correct |
28 |
Correct |
4 ms |
364 KB |
Output is correct |
29 |
Correct |
4 ms |
364 KB |
Output is correct |
30 |
Correct |
2 ms |
364 KB |
Output is correct |
31 |
Correct |
4 ms |
364 KB |
Output is correct |
32 |
Correct |
2 ms |
364 KB |
Output is correct |
33 |
Correct |
4 ms |
364 KB |
Output is correct |
34 |
Correct |
4 ms |
364 KB |
Output is correct |
35 |
Correct |
4 ms |
364 KB |
Output is correct |
36 |
Correct |
2 ms |
364 KB |
Output is correct |
37 |
Correct |
14 ms |
492 KB |
Output is correct |
38 |
Correct |
15 ms |
492 KB |
Output is correct |
39 |
Correct |
51 ms |
748 KB |
Output is correct |
40 |
Correct |
38 ms |
620 KB |
Output is correct |
41 |
Correct |
67 ms |
1004 KB |
Output is correct |
42 |
Correct |
27 ms |
640 KB |
Output is correct |
43 |
Correct |
53 ms |
876 KB |
Output is correct |
44 |
Correct |
50 ms |
876 KB |
Output is correct |
45 |
Correct |
50 ms |
876 KB |
Output is correct |
46 |
Correct |
28 ms |
620 KB |
Output is correct |
47 |
Correct |
29 ms |
620 KB |
Output is correct |
48 |
Correct |
53 ms |
876 KB |
Output is correct |
49 |
Correct |
51 ms |
876 KB |
Output is correct |
50 |
Correct |
29 ms |
640 KB |
Output is correct |
51 |
Correct |
26 ms |
620 KB |
Output is correct |
52 |
Correct |
66 ms |
1004 KB |
Output is correct |
53 |
Correct |
50 ms |
748 KB |
Output is correct |
54 |
Correct |
66 ms |
876 KB |
Output is correct |
55 |
Correct |
135 ms |
1516 KB |
Output is correct |
56 |
Correct |
62 ms |
876 KB |
Output is correct |
57 |
Correct |
142 ms |
1516 KB |
Output is correct |
58 |
Correct |
74 ms |
1004 KB |
Output is correct |
59 |
Correct |
96 ms |
1132 KB |
Output is correct |
60 |
Correct |
70 ms |
876 KB |
Output is correct |
61 |
Correct |
102 ms |
1260 KB |
Output is correct |
62 |
Correct |
107 ms |
1388 KB |
Output is correct |
63 |
Correct |
116 ms |
1388 KB |
Output is correct |
64 |
Correct |
114 ms |
1388 KB |
Output is correct |
65 |
Correct |
50 ms |
748 KB |
Output is correct |
66 |
Correct |
57 ms |
748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
0 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
2 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
364 KB |
Output is correct |
24 |
Correct |
3 ms |
364 KB |
Output is correct |
25 |
Correct |
4 ms |
364 KB |
Output is correct |
26 |
Correct |
4 ms |
364 KB |
Output is correct |
27 |
Correct |
4 ms |
364 KB |
Output is correct |
28 |
Correct |
4 ms |
364 KB |
Output is correct |
29 |
Correct |
4 ms |
364 KB |
Output is correct |
30 |
Correct |
2 ms |
364 KB |
Output is correct |
31 |
Correct |
4 ms |
364 KB |
Output is correct |
32 |
Correct |
2 ms |
364 KB |
Output is correct |
33 |
Correct |
4 ms |
364 KB |
Output is correct |
34 |
Correct |
4 ms |
364 KB |
Output is correct |
35 |
Correct |
4 ms |
364 KB |
Output is correct |
36 |
Correct |
2 ms |
364 KB |
Output is correct |
37 |
Correct |
14 ms |
492 KB |
Output is correct |
38 |
Correct |
15 ms |
492 KB |
Output is correct |
39 |
Correct |
51 ms |
748 KB |
Output is correct |
40 |
Correct |
38 ms |
620 KB |
Output is correct |
41 |
Correct |
67 ms |
1004 KB |
Output is correct |
42 |
Correct |
27 ms |
640 KB |
Output is correct |
43 |
Correct |
53 ms |
876 KB |
Output is correct |
44 |
Correct |
50 ms |
876 KB |
Output is correct |
45 |
Correct |
50 ms |
876 KB |
Output is correct |
46 |
Correct |
28 ms |
620 KB |
Output is correct |
47 |
Correct |
29 ms |
620 KB |
Output is correct |
48 |
Correct |
53 ms |
876 KB |
Output is correct |
49 |
Correct |
51 ms |
876 KB |
Output is correct |
50 |
Correct |
29 ms |
640 KB |
Output is correct |
51 |
Correct |
26 ms |
620 KB |
Output is correct |
52 |
Correct |
66 ms |
1004 KB |
Output is correct |
53 |
Correct |
50 ms |
748 KB |
Output is correct |
54 |
Correct |
66 ms |
876 KB |
Output is correct |
55 |
Correct |
135 ms |
1516 KB |
Output is correct |
56 |
Correct |
62 ms |
876 KB |
Output is correct |
57 |
Correct |
142 ms |
1516 KB |
Output is correct |
58 |
Correct |
74 ms |
1004 KB |
Output is correct |
59 |
Correct |
96 ms |
1132 KB |
Output is correct |
60 |
Correct |
70 ms |
876 KB |
Output is correct |
61 |
Correct |
102 ms |
1260 KB |
Output is correct |
62 |
Correct |
107 ms |
1388 KB |
Output is correct |
63 |
Correct |
116 ms |
1388 KB |
Output is correct |
64 |
Correct |
114 ms |
1388 KB |
Output is correct |
65 |
Correct |
50 ms |
748 KB |
Output is correct |
66 |
Correct |
57 ms |
748 KB |
Output is correct |
67 |
Correct |
106 ms |
1132 KB |
Output is correct |
68 |
Correct |
198 ms |
1260 KB |
Output is correct |
69 |
Correct |
413 ms |
2668 KB |
Output is correct |
70 |
Correct |
215 ms |
1772 KB |
Output is correct |
71 |
Correct |
218 ms |
1736 KB |
Output is correct |
72 |
Correct |
205 ms |
1388 KB |
Output is correct |
73 |
Correct |
202 ms |
1388 KB |
Output is correct |
74 |
Correct |
387 ms |
2924 KB |
Output is correct |
75 |
Correct |
294 ms |
2284 KB |
Output is correct |
76 |
Correct |
431 ms |
2924 KB |
Output is correct |
77 |
Correct |
432 ms |
2876 KB |
Output is correct |