# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
36156 | 2017-12-06T05:03:26 Z | Dat160601 | Bootfall (IZhO17_bootfall) | C++14 | 526 ms | 5800 KB |
#include <bits/stdc++.h> using namespace std; #define pb push_back vector <int> ans; int n,a[507],sum[507],dp[250007],save[250007],res[250007]; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d",&a[i]); sum[i]=sum[i-1]+a[i]; } if(sum[n]%2==1){ printf("0"); return 0; } save[0]=1; save[a[1]]=1; for(int i=2;i<=n;i++){ for(int j=0;j<=sum[i];j++){ if(j<a[i]) dp[j]=save[j]; else dp[j]=save[j]+save[j-a[i]]; } for(int j=0;j<=sum[i];j++) save[j]=dp[j]; } if(dp[sum[n]/2]==0){ printf("0"); return 0; } for(int i=1;i<=n;i++){ for(int j=0;j<=sum[n];j++) save[j]=dp[j]; for(int j=0;j<=sum[n];j++){ if(j>=a[i]) save[j]-=save[j-a[i]]; } for(int j=sum[n];j>=1;j--){ int val=sum[n]+j-a[i]; if(val%2==1 || save[val/2]==0) continue; res[j]++; } } for(int j=1;j<=sum[n];j++){ if(res[j]==n) ans.pb(j); } printf("%d\n",(int)ans.size()); for(int i=0;i<(int)ans.size();i++) printf("%d ",ans[i]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 4948 KB | Output is correct |
2 | Correct | 0 ms | 4948 KB | Output is correct |
3 | Correct | 0 ms | 4948 KB | Output is correct |
4 | Correct | 0 ms | 4948 KB | Output is correct |
5 | Correct | 0 ms | 4948 KB | Output is correct |
6 | Correct | 0 ms | 4948 KB | Output is correct |
7 | Correct | 0 ms | 4948 KB | Output is correct |
8 | Correct | 0 ms | 4948 KB | Output is correct |
9 | Correct | 0 ms | 4948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 4948 KB | Output is correct |
2 | Correct | 0 ms | 4948 KB | Output is correct |
3 | Correct | 0 ms | 4948 KB | Output is correct |
4 | Correct | 0 ms | 4948 KB | Output is correct |
5 | Correct | 0 ms | 4948 KB | Output is correct |
6 | Correct | 0 ms | 4948 KB | Output is correct |
7 | Correct | 0 ms | 4948 KB | Output is correct |
8 | Correct | 0 ms | 4948 KB | Output is correct |
9 | Correct | 0 ms | 4948 KB | Output is correct |
10 | Correct | 0 ms | 4948 KB | Output is correct |
11 | Correct | 0 ms | 4948 KB | Output is correct |
12 | Correct | 0 ms | 4948 KB | Output is correct |
13 | Correct | 0 ms | 4948 KB | Output is correct |
14 | Correct | 0 ms | 4948 KB | Output is correct |
15 | Correct | 0 ms | 4948 KB | Output is correct |
16 | Correct | 0 ms | 4948 KB | Output is correct |
17 | Correct | 0 ms | 4948 KB | Output is correct |
18 | Correct | 0 ms | 4948 KB | Output is correct |
19 | Correct | 0 ms | 4948 KB | Output is correct |
20 | Correct | 0 ms | 4948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 4948 KB | Output is correct |
2 | Correct | 0 ms | 4948 KB | Output is correct |
3 | Correct | 0 ms | 4948 KB | Output is correct |
4 | Correct | 0 ms | 4948 KB | Output is correct |
5 | Correct | 0 ms | 4948 KB | Output is correct |
6 | Correct | 0 ms | 4948 KB | Output is correct |
7 | Correct | 0 ms | 4948 KB | Output is correct |
8 | Correct | 0 ms | 4948 KB | Output is correct |
9 | Correct | 0 ms | 4948 KB | Output is correct |
10 | Correct | 0 ms | 4948 KB | Output is correct |
11 | Correct | 0 ms | 4948 KB | Output is correct |
12 | Correct | 0 ms | 4948 KB | Output is correct |
13 | Correct | 0 ms | 4948 KB | Output is correct |
14 | Correct | 0 ms | 4948 KB | Output is correct |
15 | Correct | 0 ms | 4948 KB | Output is correct |
16 | Correct | 0 ms | 4948 KB | Output is correct |
17 | Correct | 0 ms | 4948 KB | Output is correct |
18 | Correct | 0 ms | 4948 KB | Output is correct |
19 | Correct | 0 ms | 4948 KB | Output is correct |
20 | Correct | 0 ms | 4948 KB | Output is correct |
21 | Correct | 0 ms | 4948 KB | Output is correct |
22 | Correct | 0 ms | 4948 KB | Output is correct |
23 | Correct | 0 ms | 4948 KB | Output is correct |
24 | Correct | 0 ms | 4948 KB | Output is correct |
25 | Correct | 3 ms | 4948 KB | Output is correct |
26 | Correct | 3 ms | 4948 KB | Output is correct |
27 | Correct | 3 ms | 4948 KB | Output is correct |
28 | Correct | 3 ms | 4948 KB | Output is correct |
29 | Correct | 3 ms | 4948 KB | Output is correct |
30 | Correct | 0 ms | 4948 KB | Output is correct |
31 | Correct | 3 ms | 4948 KB | Output is correct |
32 | Correct | 0 ms | 4948 KB | Output is correct |
33 | Correct | 3 ms | 4948 KB | Output is correct |
34 | Correct | 3 ms | 4948 KB | Output is correct |
35 | Correct | 3 ms | 4948 KB | Output is correct |
36 | Correct | 0 ms | 4948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 4948 KB | Output is correct |
2 | Correct | 0 ms | 4948 KB | Output is correct |
3 | Correct | 0 ms | 4948 KB | Output is correct |
4 | Correct | 0 ms | 4948 KB | Output is correct |
5 | Correct | 0 ms | 4948 KB | Output is correct |
6 | Correct | 0 ms | 4948 KB | Output is correct |
7 | Correct | 0 ms | 4948 KB | Output is correct |
8 | Correct | 0 ms | 4948 KB | Output is correct |
9 | Correct | 0 ms | 4948 KB | Output is correct |
10 | Correct | 0 ms | 4948 KB | Output is correct |
11 | Correct | 0 ms | 4948 KB | Output is correct |
12 | Correct | 0 ms | 4948 KB | Output is correct |
13 | Correct | 0 ms | 4948 KB | Output is correct |
14 | Correct | 0 ms | 4948 KB | Output is correct |
15 | Correct | 0 ms | 4948 KB | Output is correct |
16 | Correct | 0 ms | 4948 KB | Output is correct |
17 | Correct | 0 ms | 4948 KB | Output is correct |
18 | Correct | 0 ms | 4948 KB | Output is correct |
19 | Correct | 0 ms | 4948 KB | Output is correct |
20 | Correct | 0 ms | 4948 KB | Output is correct |
21 | Correct | 0 ms | 4948 KB | Output is correct |
22 | Correct | 0 ms | 4948 KB | Output is correct |
23 | Correct | 0 ms | 4948 KB | Output is correct |
24 | Correct | 0 ms | 4948 KB | Output is correct |
25 | Correct | 3 ms | 4948 KB | Output is correct |
26 | Correct | 3 ms | 4948 KB | Output is correct |
27 | Correct | 3 ms | 4948 KB | Output is correct |
28 | Correct | 3 ms | 4948 KB | Output is correct |
29 | Correct | 3 ms | 4948 KB | Output is correct |
30 | Correct | 0 ms | 4948 KB | Output is correct |
31 | Correct | 3 ms | 4948 KB | Output is correct |
32 | Correct | 0 ms | 4948 KB | Output is correct |
33 | Correct | 3 ms | 4948 KB | Output is correct |
34 | Correct | 3 ms | 4948 KB | Output is correct |
35 | Correct | 3 ms | 4948 KB | Output is correct |
36 | Correct | 0 ms | 4948 KB | Output is correct |
37 | Correct | 16 ms | 5088 KB | Output is correct |
38 | Correct | 16 ms | 5088 KB | Output is correct |
39 | Correct | 59 ms | 4948 KB | Output is correct |
40 | Correct | 36 ms | 5088 KB | Output is correct |
41 | Correct | 79 ms | 4948 KB | Output is correct |
42 | Correct | 33 ms | 5088 KB | Output is correct |
43 | Correct | 53 ms | 5220 KB | Output is correct |
44 | Correct | 86 ms | 5220 KB | Output is correct |
45 | Correct | 79 ms | 5220 KB | Output is correct |
46 | Correct | 29 ms | 4948 KB | Output is correct |
47 | Correct | 36 ms | 5088 KB | Output is correct |
48 | Correct | 66 ms | 5220 KB | Output is correct |
49 | Correct | 63 ms | 5088 KB | Output is correct |
50 | Correct | 36 ms | 5088 KB | Output is correct |
51 | Correct | 0 ms | 4948 KB | Output is correct |
52 | Correct | 79 ms | 5220 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 4948 KB | Output is correct |
2 | Correct | 0 ms | 4948 KB | Output is correct |
3 | Correct | 0 ms | 4948 KB | Output is correct |
4 | Correct | 0 ms | 4948 KB | Output is correct |
5 | Correct | 0 ms | 4948 KB | Output is correct |
6 | Correct | 0 ms | 4948 KB | Output is correct |
7 | Correct | 0 ms | 4948 KB | Output is correct |
8 | Correct | 0 ms | 4948 KB | Output is correct |
9 | Correct | 0 ms | 4948 KB | Output is correct |
10 | Correct | 0 ms | 4948 KB | Output is correct |
11 | Correct | 0 ms | 4948 KB | Output is correct |
12 | Correct | 0 ms | 4948 KB | Output is correct |
13 | Correct | 0 ms | 4948 KB | Output is correct |
14 | Correct | 0 ms | 4948 KB | Output is correct |
15 | Correct | 0 ms | 4948 KB | Output is correct |
16 | Correct | 0 ms | 4948 KB | Output is correct |
17 | Correct | 0 ms | 4948 KB | Output is correct |
18 | Correct | 0 ms | 4948 KB | Output is correct |
19 | Correct | 0 ms | 4948 KB | Output is correct |
20 | Correct | 0 ms | 4948 KB | Output is correct |
21 | Correct | 0 ms | 4948 KB | Output is correct |
22 | Correct | 0 ms | 4948 KB | Output is correct |
23 | Correct | 0 ms | 4948 KB | Output is correct |
24 | Correct | 0 ms | 4948 KB | Output is correct |
25 | Correct | 3 ms | 4948 KB | Output is correct |
26 | Correct | 3 ms | 4948 KB | Output is correct |
27 | Correct | 3 ms | 4948 KB | Output is correct |
28 | Correct | 3 ms | 4948 KB | Output is correct |
29 | Correct | 3 ms | 4948 KB | Output is correct |
30 | Correct | 0 ms | 4948 KB | Output is correct |
31 | Correct | 3 ms | 4948 KB | Output is correct |
32 | Correct | 0 ms | 4948 KB | Output is correct |
33 | Correct | 3 ms | 4948 KB | Output is correct |
34 | Correct | 3 ms | 4948 KB | Output is correct |
35 | Correct | 3 ms | 4948 KB | Output is correct |
36 | Correct | 0 ms | 4948 KB | Output is correct |
37 | Correct | 16 ms | 5088 KB | Output is correct |
38 | Correct | 16 ms | 5088 KB | Output is correct |
39 | Correct | 59 ms | 4948 KB | Output is correct |
40 | Correct | 36 ms | 5088 KB | Output is correct |
41 | Correct | 79 ms | 4948 KB | Output is correct |
42 | Correct | 33 ms | 5088 KB | Output is correct |
43 | Correct | 53 ms | 5220 KB | Output is correct |
44 | Correct | 86 ms | 5220 KB | Output is correct |
45 | Correct | 79 ms | 5220 KB | Output is correct |
46 | Correct | 29 ms | 4948 KB | Output is correct |
47 | Correct | 36 ms | 5088 KB | Output is correct |
48 | Correct | 66 ms | 5220 KB | Output is correct |
49 | Correct | 63 ms | 5088 KB | Output is correct |
50 | Correct | 36 ms | 5088 KB | Output is correct |
51 | Correct | 0 ms | 4948 KB | Output is correct |
52 | Correct | 79 ms | 5220 KB | Output is correct |
53 | Correct | 59 ms | 5220 KB | Output is correct |
54 | Correct | 86 ms | 5220 KB | Output is correct |
55 | Correct | 173 ms | 5416 KB | Output is correct |
56 | Correct | 89 ms | 5220 KB | Output is correct |
57 | Correct | 189 ms | 5416 KB | Output is correct |
58 | Correct | 89 ms | 5220 KB | Output is correct |
59 | Correct | 116 ms | 5416 KB | Output is correct |
60 | Correct | 0 ms | 4948 KB | Output is correct |
61 | Correct | 139 ms | 5416 KB | Output is correct |
62 | Correct | 143 ms | 5416 KB | Output is correct |
63 | Correct | 143 ms | 5416 KB | Output is correct |
64 | Correct | 203 ms | 5416 KB | Output is correct |
65 | Correct | 66 ms | 4948 KB | Output is correct |
66 | Correct | 76 ms | 5088 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 4948 KB | Output is correct |
2 | Correct | 0 ms | 4948 KB | Output is correct |
3 | Correct | 0 ms | 4948 KB | Output is correct |
4 | Correct | 0 ms | 4948 KB | Output is correct |
5 | Correct | 0 ms | 4948 KB | Output is correct |
6 | Correct | 0 ms | 4948 KB | Output is correct |
7 | Correct | 0 ms | 4948 KB | Output is correct |
8 | Correct | 0 ms | 4948 KB | Output is correct |
9 | Correct | 0 ms | 4948 KB | Output is correct |
10 | Correct | 0 ms | 4948 KB | Output is correct |
11 | Correct | 0 ms | 4948 KB | Output is correct |
12 | Correct | 0 ms | 4948 KB | Output is correct |
13 | Correct | 0 ms | 4948 KB | Output is correct |
14 | Correct | 0 ms | 4948 KB | Output is correct |
15 | Correct | 0 ms | 4948 KB | Output is correct |
16 | Correct | 0 ms | 4948 KB | Output is correct |
17 | Correct | 0 ms | 4948 KB | Output is correct |
18 | Correct | 0 ms | 4948 KB | Output is correct |
19 | Correct | 0 ms | 4948 KB | Output is correct |
20 | Correct | 0 ms | 4948 KB | Output is correct |
21 | Correct | 0 ms | 4948 KB | Output is correct |
22 | Correct | 0 ms | 4948 KB | Output is correct |
23 | Correct | 0 ms | 4948 KB | Output is correct |
24 | Correct | 0 ms | 4948 KB | Output is correct |
25 | Correct | 3 ms | 4948 KB | Output is correct |
26 | Correct | 3 ms | 4948 KB | Output is correct |
27 | Correct | 3 ms | 4948 KB | Output is correct |
28 | Correct | 3 ms | 4948 KB | Output is correct |
29 | Correct | 3 ms | 4948 KB | Output is correct |
30 | Correct | 0 ms | 4948 KB | Output is correct |
31 | Correct | 3 ms | 4948 KB | Output is correct |
32 | Correct | 0 ms | 4948 KB | Output is correct |
33 | Correct | 3 ms | 4948 KB | Output is correct |
34 | Correct | 3 ms | 4948 KB | Output is correct |
35 | Correct | 3 ms | 4948 KB | Output is correct |
36 | Correct | 0 ms | 4948 KB | Output is correct |
37 | Correct | 16 ms | 5088 KB | Output is correct |
38 | Correct | 16 ms | 5088 KB | Output is correct |
39 | Correct | 59 ms | 4948 KB | Output is correct |
40 | Correct | 36 ms | 5088 KB | Output is correct |
41 | Correct | 79 ms | 4948 KB | Output is correct |
42 | Correct | 33 ms | 5088 KB | Output is correct |
43 | Correct | 53 ms | 5220 KB | Output is correct |
44 | Correct | 86 ms | 5220 KB | Output is correct |
45 | Correct | 79 ms | 5220 KB | Output is correct |
46 | Correct | 29 ms | 4948 KB | Output is correct |
47 | Correct | 36 ms | 5088 KB | Output is correct |
48 | Correct | 66 ms | 5220 KB | Output is correct |
49 | Correct | 63 ms | 5088 KB | Output is correct |
50 | Correct | 36 ms | 5088 KB | Output is correct |
51 | Correct | 0 ms | 4948 KB | Output is correct |
52 | Correct | 79 ms | 5220 KB | Output is correct |
53 | Correct | 59 ms | 5220 KB | Output is correct |
54 | Correct | 86 ms | 5220 KB | Output is correct |
55 | Correct | 173 ms | 5416 KB | Output is correct |
56 | Correct | 89 ms | 5220 KB | Output is correct |
57 | Correct | 189 ms | 5416 KB | Output is correct |
58 | Correct | 89 ms | 5220 KB | Output is correct |
59 | Correct | 116 ms | 5416 KB | Output is correct |
60 | Correct | 0 ms | 4948 KB | Output is correct |
61 | Correct | 139 ms | 5416 KB | Output is correct |
62 | Correct | 143 ms | 5416 KB | Output is correct |
63 | Correct | 143 ms | 5416 KB | Output is correct |
64 | Correct | 203 ms | 5416 KB | Output is correct |
65 | Correct | 66 ms | 4948 KB | Output is correct |
66 | Correct | 76 ms | 5088 KB | Output is correct |
67 | Correct | 123 ms | 5416 KB | Output is correct |
68 | Correct | 59 ms | 4948 KB | Output is correct |
69 | Correct | 463 ms | 5800 KB | Output is correct |
70 | Correct | 303 ms | 5416 KB | Output is correct |
71 | Correct | 276 ms | 5416 KB | Output is correct |
72 | Correct | 269 ms | 4948 KB | Output is correct |
73 | Correct | 253 ms | 4948 KB | Output is correct |
74 | Correct | 479 ms | 5800 KB | Output is correct |
75 | Correct | 373 ms | 5800 KB | Output is correct |
76 | Correct | 526 ms | 5800 KB | Output is correct |
77 | Correct | 516 ms | 5800 KB | Output is correct |