# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
91237 | 2018-12-26T15:42:59 Z | Vardanyan | Bootfall (IZhO17_bootfall) | C++14 | 977 ms | 245172 KB |
#include<bits/stdc++.h> using namespace std; const int N = 505; bool dp[N][N*N*2]; int a[N]; int dp1[N*N*2]; int main() { int n; scanf("%d",&n); int MX = 0; int sum = 0; for(int i = 1;i<=n;i++){ scanf("%d",&a[i]); MX+=a[i]; sum+=a[i]; } sort(a+1,a+1+n); dp1[0] = 1; for(int j = 1;j<=n;j++){ for(int s = 2*MX;s>=0;s--){ if(dp1[s]) dp1[s+a[j]] += dp1[s]; } } for(int i = 1;i<=n;i++){ for(int s = 0;s<=2*MX;s++) dp1[s+a[i]] -= dp1[s]; for(int s = 0;s<=2*MX;s++) dp[i][s] = dp1[s]; for(int s = 2*MX;s>=0;s--) dp1[s+a[i]] += dp1[s]; } if(!dp1[sum/2]){ printf("0\n"); return 0; } vector<int> ans; for(int x = 1;x<=MX;x++){ sum+=x; bool F = true; for(int i = 1;i<=n;i++){ sum-=a[i]; int need = sum/2; sum+=a[i]; if(need-x<0){ F = false; break; } if(dp[i][need-x] && (sum-a[i])%2 == 0) continue; F = false; break; } sum-=x; if(F) ans.push_back(x); } printf("%d\n",ans.size()); for(int i = 0;i<ans.size();i++) printf("%d ",ans[i]); printf("\n"); return 0; }
Compilation message
# | 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 | 456 KB | Output is correct |
4 | Correct | 2 ms | 500 KB | Output is correct |
5 | Correct | 2 ms | 576 KB | Output is correct |
6 | Correct | 2 ms | 592 KB | Output is correct |
7 | Correct | 2 ms | 592 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 | 456 KB | Output is correct |
4 | Correct | 2 ms | 500 KB | Output is correct |
5 | Correct | 2 ms | 576 KB | Output is correct |
6 | Correct | 2 ms | 592 KB | Output is correct |
7 | Correct | 2 ms | 592 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 | 740 KB | Output is correct |
11 | Correct | 2 ms | 748 KB | Output is correct |
12 | Correct | 2 ms | 748 KB | Output is correct |
13 | Correct | 2 ms | 748 KB | Output is correct |
14 | Correct | 2 ms | 748 KB | Output is correct |
15 | Correct | 2 ms | 748 KB | Output is correct |
16 | Correct | 2 ms | 748 KB | Output is correct |
17 | Correct | 2 ms | 748 KB | Output is correct |
18 | Correct | 2 ms | 764 KB | Output is correct |
19 | Correct | 2 ms | 764 KB | Output is correct |
20 | Correct | 2 ms | 764 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 | 456 KB | Output is correct |
4 | Correct | 2 ms | 500 KB | Output is correct |
5 | Correct | 2 ms | 576 KB | Output is correct |
6 | Correct | 2 ms | 592 KB | Output is correct |
7 | Correct | 2 ms | 592 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 | 740 KB | Output is correct |
11 | Correct | 2 ms | 748 KB | Output is correct |
12 | Correct | 2 ms | 748 KB | Output is correct |
13 | Correct | 2 ms | 748 KB | Output is correct |
14 | Correct | 2 ms | 748 KB | Output is correct |
15 | Correct | 2 ms | 748 KB | Output is correct |
16 | Correct | 2 ms | 748 KB | Output is correct |
17 | Correct | 2 ms | 748 KB | Output is correct |
18 | Correct | 2 ms | 764 KB | Output is correct |
19 | Correct | 2 ms | 764 KB | Output is correct |
20 | Correct | 2 ms | 764 KB | Output is correct |
21 | Correct | 4 ms | 1404 KB | Output is correct |
22 | Correct | 4 ms | 1532 KB | Output is correct |
23 | Correct | 3 ms | 1532 KB | Output is correct |
24 | Correct | 5 ms | 1948 KB | Output is correct |
25 | Correct | 9 ms | 2844 KB | Output is correct |
26 | Correct | 9 ms | 3116 KB | Output is correct |
27 | Correct | 9 ms | 3116 KB | Output is correct |
28 | Correct | 9 ms | 3132 KB | Output is correct |
29 | Correct | 9 ms | 3132 KB | Output is correct |
30 | Correct | 5 ms | 3132 KB | Output is correct |
31 | Correct | 8 ms | 3132 KB | Output is correct |
32 | Correct | 6 ms | 3132 KB | Output is correct |
33 | Correct | 8 ms | 3132 KB | Output is correct |
34 | Correct | 8 ms | 3132 KB | Output is correct |
35 | Correct | 9 ms | 3132 KB | Output is correct |
36 | Correct | 6 ms | 3132 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 | 456 KB | Output is correct |
4 | Correct | 2 ms | 500 KB | Output is correct |
5 | Correct | 2 ms | 576 KB | Output is correct |
6 | Correct | 2 ms | 592 KB | Output is correct |
7 | Correct | 2 ms | 592 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 | 740 KB | Output is correct |
11 | Correct | 2 ms | 748 KB | Output is correct |
12 | Correct | 2 ms | 748 KB | Output is correct |
13 | Correct | 2 ms | 748 KB | Output is correct |
14 | Correct | 2 ms | 748 KB | Output is correct |
15 | Correct | 2 ms | 748 KB | Output is correct |
16 | Correct | 2 ms | 748 KB | Output is correct |
17 | Correct | 2 ms | 748 KB | Output is correct |
18 | Correct | 2 ms | 764 KB | Output is correct |
19 | Correct | 2 ms | 764 KB | Output is correct |
20 | Correct | 2 ms | 764 KB | Output is correct |
21 | Correct | 4 ms | 1404 KB | Output is correct |
22 | Correct | 4 ms | 1532 KB | Output is correct |
23 | Correct | 3 ms | 1532 KB | Output is correct |
24 | Correct | 5 ms | 1948 KB | Output is correct |
25 | Correct | 9 ms | 2844 KB | Output is correct |
26 | Correct | 9 ms | 3116 KB | Output is correct |
27 | Correct | 9 ms | 3116 KB | Output is correct |
28 | Correct | 9 ms | 3132 KB | Output is correct |
29 | Correct | 9 ms | 3132 KB | Output is correct |
30 | Correct | 5 ms | 3132 KB | Output is correct |
31 | Correct | 8 ms | 3132 KB | Output is correct |
32 | Correct | 6 ms | 3132 KB | Output is correct |
33 | Correct | 8 ms | 3132 KB | Output is correct |
34 | Correct | 8 ms | 3132 KB | Output is correct |
35 | Correct | 9 ms | 3132 KB | Output is correct |
36 | Correct | 6 ms | 3132 KB | Output is correct |
37 | Correct | 37 ms | 9460 KB | Output is correct |
38 | Correct | 38 ms | 9744 KB | Output is correct |
39 | Correct | 94 ms | 32316 KB | Output is correct |
40 | Correct | 72 ms | 32316 KB | Output is correct |
41 | Correct | 128 ms | 40976 KB | Output is correct |
42 | Correct | 61 ms | 40976 KB | Output is correct |
43 | Correct | 117 ms | 40976 KB | Output is correct |
44 | Correct | 120 ms | 40976 KB | Output is correct |
45 | Correct | 123 ms | 40976 KB | Output is correct |
46 | Correct | 55 ms | 40976 KB | Output is correct |
47 | Correct | 71 ms | 40976 KB | Output is correct |
48 | Correct | 130 ms | 40976 KB | Output is correct |
49 | Correct | 105 ms | 40976 KB | Output is correct |
50 | Correct | 67 ms | 40976 KB | Output is correct |
51 | Correct | 56 ms | 40976 KB | Output is correct |
52 | Correct | 158 ms | 40976 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 | 456 KB | Output is correct |
4 | Correct | 2 ms | 500 KB | Output is correct |
5 | Correct | 2 ms | 576 KB | Output is correct |
6 | Correct | 2 ms | 592 KB | Output is correct |
7 | Correct | 2 ms | 592 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 | 740 KB | Output is correct |
11 | Correct | 2 ms | 748 KB | Output is correct |
12 | Correct | 2 ms | 748 KB | Output is correct |
13 | Correct | 2 ms | 748 KB | Output is correct |
14 | Correct | 2 ms | 748 KB | Output is correct |
15 | Correct | 2 ms | 748 KB | Output is correct |
16 | Correct | 2 ms | 748 KB | Output is correct |
17 | Correct | 2 ms | 748 KB | Output is correct |
18 | Correct | 2 ms | 764 KB | Output is correct |
19 | Correct | 2 ms | 764 KB | Output is correct |
20 | Correct | 2 ms | 764 KB | Output is correct |
21 | Correct | 4 ms | 1404 KB | Output is correct |
22 | Correct | 4 ms | 1532 KB | Output is correct |
23 | Correct | 3 ms | 1532 KB | Output is correct |
24 | Correct | 5 ms | 1948 KB | Output is correct |
25 | Correct | 9 ms | 2844 KB | Output is correct |
26 | Correct | 9 ms | 3116 KB | Output is correct |
27 | Correct | 9 ms | 3116 KB | Output is correct |
28 | Correct | 9 ms | 3132 KB | Output is correct |
29 | Correct | 9 ms | 3132 KB | Output is correct |
30 | Correct | 5 ms | 3132 KB | Output is correct |
31 | Correct | 8 ms | 3132 KB | Output is correct |
32 | Correct | 6 ms | 3132 KB | Output is correct |
33 | Correct | 8 ms | 3132 KB | Output is correct |
34 | Correct | 8 ms | 3132 KB | Output is correct |
35 | Correct | 9 ms | 3132 KB | Output is correct |
36 | Correct | 6 ms | 3132 KB | Output is correct |
37 | Correct | 37 ms | 9460 KB | Output is correct |
38 | Correct | 38 ms | 9744 KB | Output is correct |
39 | Correct | 94 ms | 32316 KB | Output is correct |
40 | Correct | 72 ms | 32316 KB | Output is correct |
41 | Correct | 128 ms | 40976 KB | Output is correct |
42 | Correct | 61 ms | 40976 KB | Output is correct |
43 | Correct | 117 ms | 40976 KB | Output is correct |
44 | Correct | 120 ms | 40976 KB | Output is correct |
45 | Correct | 123 ms | 40976 KB | Output is correct |
46 | Correct | 55 ms | 40976 KB | Output is correct |
47 | Correct | 71 ms | 40976 KB | Output is correct |
48 | Correct | 130 ms | 40976 KB | Output is correct |
49 | Correct | 105 ms | 40976 KB | Output is correct |
50 | Correct | 67 ms | 40976 KB | Output is correct |
51 | Correct | 56 ms | 40976 KB | Output is correct |
52 | Correct | 158 ms | 40976 KB | Output is correct |
53 | Correct | 121 ms | 40976 KB | Output is correct |
54 | Correct | 165 ms | 41148 KB | Output is correct |
55 | Correct | 327 ms | 79800 KB | Output is correct |
56 | Correct | 149 ms | 79800 KB | Output is correct |
57 | Correct | 339 ms | 83924 KB | Output is correct |
58 | Correct | 196 ms | 83924 KB | Output is correct |
59 | Correct | 229 ms | 83924 KB | Output is correct |
60 | Correct | 137 ms | 83924 KB | Output is correct |
61 | Correct | 261 ms | 83924 KB | Output is correct |
62 | Correct | 264 ms | 83924 KB | Output is correct |
63 | Correct | 280 ms | 83924 KB | Output is correct |
64 | Correct | 293 ms | 83924 KB | Output is correct |
65 | Correct | 114 ms | 83924 KB | Output is correct |
66 | Correct | 124 ms | 83924 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 | 456 KB | Output is correct |
4 | Correct | 2 ms | 500 KB | Output is correct |
5 | Correct | 2 ms | 576 KB | Output is correct |
6 | Correct | 2 ms | 592 KB | Output is correct |
7 | Correct | 2 ms | 592 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 | 740 KB | Output is correct |
11 | Correct | 2 ms | 748 KB | Output is correct |
12 | Correct | 2 ms | 748 KB | Output is correct |
13 | Correct | 2 ms | 748 KB | Output is correct |
14 | Correct | 2 ms | 748 KB | Output is correct |
15 | Correct | 2 ms | 748 KB | Output is correct |
16 | Correct | 2 ms | 748 KB | Output is correct |
17 | Correct | 2 ms | 748 KB | Output is correct |
18 | Correct | 2 ms | 764 KB | Output is correct |
19 | Correct | 2 ms | 764 KB | Output is correct |
20 | Correct | 2 ms | 764 KB | Output is correct |
21 | Correct | 4 ms | 1404 KB | Output is correct |
22 | Correct | 4 ms | 1532 KB | Output is correct |
23 | Correct | 3 ms | 1532 KB | Output is correct |
24 | Correct | 5 ms | 1948 KB | Output is correct |
25 | Correct | 9 ms | 2844 KB | Output is correct |
26 | Correct | 9 ms | 3116 KB | Output is correct |
27 | Correct | 9 ms | 3116 KB | Output is correct |
28 | Correct | 9 ms | 3132 KB | Output is correct |
29 | Correct | 9 ms | 3132 KB | Output is correct |
30 | Correct | 5 ms | 3132 KB | Output is correct |
31 | Correct | 8 ms | 3132 KB | Output is correct |
32 | Correct | 6 ms | 3132 KB | Output is correct |
33 | Correct | 8 ms | 3132 KB | Output is correct |
34 | Correct | 8 ms | 3132 KB | Output is correct |
35 | Correct | 9 ms | 3132 KB | Output is correct |
36 | Correct | 6 ms | 3132 KB | Output is correct |
37 | Correct | 37 ms | 9460 KB | Output is correct |
38 | Correct | 38 ms | 9744 KB | Output is correct |
39 | Correct | 94 ms | 32316 KB | Output is correct |
40 | Correct | 72 ms | 32316 KB | Output is correct |
41 | Correct | 128 ms | 40976 KB | Output is correct |
42 | Correct | 61 ms | 40976 KB | Output is correct |
43 | Correct | 117 ms | 40976 KB | Output is correct |
44 | Correct | 120 ms | 40976 KB | Output is correct |
45 | Correct | 123 ms | 40976 KB | Output is correct |
46 | Correct | 55 ms | 40976 KB | Output is correct |
47 | Correct | 71 ms | 40976 KB | Output is correct |
48 | Correct | 130 ms | 40976 KB | Output is correct |
49 | Correct | 105 ms | 40976 KB | Output is correct |
50 | Correct | 67 ms | 40976 KB | Output is correct |
51 | Correct | 56 ms | 40976 KB | Output is correct |
52 | Correct | 158 ms | 40976 KB | Output is correct |
53 | Correct | 121 ms | 40976 KB | Output is correct |
54 | Correct | 165 ms | 41148 KB | Output is correct |
55 | Correct | 327 ms | 79800 KB | Output is correct |
56 | Correct | 149 ms | 79800 KB | Output is correct |
57 | Correct | 339 ms | 83924 KB | Output is correct |
58 | Correct | 196 ms | 83924 KB | Output is correct |
59 | Correct | 229 ms | 83924 KB | Output is correct |
60 | Correct | 137 ms | 83924 KB | Output is correct |
61 | Correct | 261 ms | 83924 KB | Output is correct |
62 | Correct | 264 ms | 83924 KB | Output is correct |
63 | Correct | 280 ms | 83924 KB | Output is correct |
64 | Correct | 293 ms | 83924 KB | Output is correct |
65 | Correct | 114 ms | 83924 KB | Output is correct |
66 | Correct | 124 ms | 83924 KB | Output is correct |
67 | Correct | 299 ms | 83924 KB | Output is correct |
68 | Correct | 393 ms | 124864 KB | Output is correct |
69 | Correct | 967 ms | 212728 KB | Output is correct |
70 | Correct | 585 ms | 212728 KB | Output is correct |
71 | Correct | 509 ms | 212728 KB | Output is correct |
72 | Correct | 380 ms | 212728 KB | Output is correct |
73 | Correct | 409 ms | 212728 KB | Output is correct |
74 | Correct | 931 ms | 224232 KB | Output is correct |
75 | Correct | 744 ms | 224232 KB | Output is correct |
76 | Correct | 957 ms | 245172 KB | Output is correct |
77 | Correct | 977 ms | 245172 KB | Output is correct |