# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
91221 | 2018-12-26T15:10:46 Z | Vardanyan | Bootfall (IZhO17_bootfall) | C++14 | 313 ms | 263168 KB |
#include<bits/stdc++.h> using namespace std; const int N = 505; int dp[N][N*N*3]; int a[N]; 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]; dp[i][0] = 1; } sort(a+1,a+1+n); dp[0][0] = 1; for(int j = 1;j<=n;j++){ for(int s = 2*MX;s>=0;s--){ if(dp[0][s]) dp[0][s+a[j]] += dp[0][s]; } } for(int i = 1;i<=n;i++){ for(int s = 2*MX;s>=0;s--) dp[i][s] = dp[0][s]; for(int s = 0;s<=2*MX;s++) dp[i][s+a[i]] -= dp[i][s]; } //cout<<sum<<endl; //cout<<dp[0][sum/2]<<endl; if(!dp[0][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(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 | 376 KB | Output is correct |
3 | Correct | 2 ms | 416 KB | Output is correct |
4 | Correct | 2 ms | 420 KB | Output is correct |
5 | Correct | 2 ms | 556 KB | Output is correct |
6 | Correct | 2 ms | 556 KB | Output is correct |
7 | Correct | 2 ms | 556 KB | Output is correct |
8 | Correct | 2 ms | 768 KB | Output is correct |
9 | Correct | 2 ms | 768 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 416 KB | Output is correct |
4 | Correct | 2 ms | 420 KB | Output is correct |
5 | Correct | 2 ms | 556 KB | Output is correct |
6 | Correct | 2 ms | 556 KB | Output is correct |
7 | Correct | 2 ms | 556 KB | Output is correct |
8 | Correct | 2 ms | 768 KB | Output is correct |
9 | Correct | 2 ms | 768 KB | Output is correct |
10 | Correct | 2 ms | 840 KB | Output is correct |
11 | Correct | 2 ms | 840 KB | Output is correct |
12 | Correct | 2 ms | 844 KB | Output is correct |
13 | Correct | 2 ms | 844 KB | Output is correct |
14 | Correct | 2 ms | 860 KB | Output is correct |
15 | Correct | 2 ms | 924 KB | Output is correct |
16 | Correct | 2 ms | 928 KB | Output is correct |
17 | Correct | 2 ms | 928 KB | Output is correct |
18 | Correct | 2 ms | 928 KB | Output is correct |
19 | Correct | 2 ms | 940 KB | Output is correct |
20 | Correct | 2 ms | 944 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 416 KB | Output is correct |
4 | Correct | 2 ms | 420 KB | Output is correct |
5 | Correct | 2 ms | 556 KB | Output is correct |
6 | Correct | 2 ms | 556 KB | Output is correct |
7 | Correct | 2 ms | 556 KB | Output is correct |
8 | Correct | 2 ms | 768 KB | Output is correct |
9 | Correct | 2 ms | 768 KB | Output is correct |
10 | Correct | 2 ms | 840 KB | Output is correct |
11 | Correct | 2 ms | 840 KB | Output is correct |
12 | Correct | 2 ms | 844 KB | Output is correct |
13 | Correct | 2 ms | 844 KB | Output is correct |
14 | Correct | 2 ms | 860 KB | Output is correct |
15 | Correct | 2 ms | 924 KB | Output is correct |
16 | Correct | 2 ms | 928 KB | Output is correct |
17 | Correct | 2 ms | 928 KB | Output is correct |
18 | Correct | 2 ms | 928 KB | Output is correct |
19 | Correct | 2 ms | 940 KB | Output is correct |
20 | Correct | 2 ms | 944 KB | Output is correct |
21 | Correct | 4 ms | 2740 KB | Output is correct |
22 | Correct | 3 ms | 3256 KB | Output is correct |
23 | Correct | 3 ms | 3256 KB | Output is correct |
24 | Correct | 7 ms | 4976 KB | Output is correct |
25 | Correct | 12 ms | 8196 KB | Output is correct |
26 | Correct | 12 ms | 9112 KB | Output is correct |
27 | Correct | 11 ms | 9112 KB | Output is correct |
28 | Correct | 12 ms | 9112 KB | Output is correct |
29 | Correct | 13 ms | 9304 KB | Output is correct |
30 | Correct | 7 ms | 9304 KB | Output is correct |
31 | Correct | 11 ms | 9304 KB | Output is correct |
32 | Correct | 8 ms | 9304 KB | Output is correct |
33 | Correct | 12 ms | 9524 KB | Output is correct |
34 | Correct | 13 ms | 9524 KB | Output is correct |
35 | Correct | 12 ms | 9524 KB | Output is correct |
36 | Correct | 7 ms | 9524 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 416 KB | Output is correct |
4 | Correct | 2 ms | 420 KB | Output is correct |
5 | Correct | 2 ms | 556 KB | Output is correct |
6 | Correct | 2 ms | 556 KB | Output is correct |
7 | Correct | 2 ms | 556 KB | Output is correct |
8 | Correct | 2 ms | 768 KB | Output is correct |
9 | Correct | 2 ms | 768 KB | Output is correct |
10 | Correct | 2 ms | 840 KB | Output is correct |
11 | Correct | 2 ms | 840 KB | Output is correct |
12 | Correct | 2 ms | 844 KB | Output is correct |
13 | Correct | 2 ms | 844 KB | Output is correct |
14 | Correct | 2 ms | 860 KB | Output is correct |
15 | Correct | 2 ms | 924 KB | Output is correct |
16 | Correct | 2 ms | 928 KB | Output is correct |
17 | Correct | 2 ms | 928 KB | Output is correct |
18 | Correct | 2 ms | 928 KB | Output is correct |
19 | Correct | 2 ms | 940 KB | Output is correct |
20 | Correct | 2 ms | 944 KB | Output is correct |
21 | Correct | 4 ms | 2740 KB | Output is correct |
22 | Correct | 3 ms | 3256 KB | Output is correct |
23 | Correct | 3 ms | 3256 KB | Output is correct |
24 | Correct | 7 ms | 4976 KB | Output is correct |
25 | Correct | 12 ms | 8196 KB | Output is correct |
26 | Correct | 12 ms | 9112 KB | Output is correct |
27 | Correct | 11 ms | 9112 KB | Output is correct |
28 | Correct | 12 ms | 9112 KB | Output is correct |
29 | Correct | 13 ms | 9304 KB | Output is correct |
30 | Correct | 7 ms | 9304 KB | Output is correct |
31 | Correct | 11 ms | 9304 KB | Output is correct |
32 | Correct | 8 ms | 9304 KB | Output is correct |
33 | Correct | 12 ms | 9524 KB | Output is correct |
34 | Correct | 13 ms | 9524 KB | Output is correct |
35 | Correct | 12 ms | 9524 KB | Output is correct |
36 | Correct | 7 ms | 9524 KB | Output is correct |
37 | Correct | 55 ms | 33092 KB | Output is correct |
38 | Correct | 49 ms | 33760 KB | Output is correct |
39 | Correct | 134 ms | 123116 KB | Output is correct |
40 | Correct | 106 ms | 123116 KB | Output is correct |
41 | Correct | 165 ms | 157648 KB | Output is correct |
42 | Correct | 91 ms | 157648 KB | Output is correct |
43 | Correct | 177 ms | 157648 KB | Output is correct |
44 | Correct | 170 ms | 157648 KB | Output is correct |
45 | Correct | 177 ms | 157648 KB | Output is correct |
46 | Correct | 76 ms | 157648 KB | Output is correct |
47 | Correct | 114 ms | 157648 KB | Output is correct |
48 | Correct | 174 ms | 157648 KB | Output is correct |
49 | Correct | 149 ms | 157648 KB | Output is correct |
50 | Correct | 99 ms | 157648 KB | Output is correct |
51 | Correct | 118 ms | 157648 KB | Output is correct |
52 | Correct | 224 ms | 157648 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 416 KB | Output is correct |
4 | Correct | 2 ms | 420 KB | Output is correct |
5 | Correct | 2 ms | 556 KB | Output is correct |
6 | Correct | 2 ms | 556 KB | Output is correct |
7 | Correct | 2 ms | 556 KB | Output is correct |
8 | Correct | 2 ms | 768 KB | Output is correct |
9 | Correct | 2 ms | 768 KB | Output is correct |
10 | Correct | 2 ms | 840 KB | Output is correct |
11 | Correct | 2 ms | 840 KB | Output is correct |
12 | Correct | 2 ms | 844 KB | Output is correct |
13 | Correct | 2 ms | 844 KB | Output is correct |
14 | Correct | 2 ms | 860 KB | Output is correct |
15 | Correct | 2 ms | 924 KB | Output is correct |
16 | Correct | 2 ms | 928 KB | Output is correct |
17 | Correct | 2 ms | 928 KB | Output is correct |
18 | Correct | 2 ms | 928 KB | Output is correct |
19 | Correct | 2 ms | 940 KB | Output is correct |
20 | Correct | 2 ms | 944 KB | Output is correct |
21 | Correct | 4 ms | 2740 KB | Output is correct |
22 | Correct | 3 ms | 3256 KB | Output is correct |
23 | Correct | 3 ms | 3256 KB | Output is correct |
24 | Correct | 7 ms | 4976 KB | Output is correct |
25 | Correct | 12 ms | 8196 KB | Output is correct |
26 | Correct | 12 ms | 9112 KB | Output is correct |
27 | Correct | 11 ms | 9112 KB | Output is correct |
28 | Correct | 12 ms | 9112 KB | Output is correct |
29 | Correct | 13 ms | 9304 KB | Output is correct |
30 | Correct | 7 ms | 9304 KB | Output is correct |
31 | Correct | 11 ms | 9304 KB | Output is correct |
32 | Correct | 8 ms | 9304 KB | Output is correct |
33 | Correct | 12 ms | 9524 KB | Output is correct |
34 | Correct | 13 ms | 9524 KB | Output is correct |
35 | Correct | 12 ms | 9524 KB | Output is correct |
36 | Correct | 7 ms | 9524 KB | Output is correct |
37 | Correct | 55 ms | 33092 KB | Output is correct |
38 | Correct | 49 ms | 33760 KB | Output is correct |
39 | Correct | 134 ms | 123116 KB | Output is correct |
40 | Correct | 106 ms | 123116 KB | Output is correct |
41 | Correct | 165 ms | 157648 KB | Output is correct |
42 | Correct | 91 ms | 157648 KB | Output is correct |
43 | Correct | 177 ms | 157648 KB | Output is correct |
44 | Correct | 170 ms | 157648 KB | Output is correct |
45 | Correct | 177 ms | 157648 KB | Output is correct |
46 | Correct | 76 ms | 157648 KB | Output is correct |
47 | Correct | 114 ms | 157648 KB | Output is correct |
48 | Correct | 174 ms | 157648 KB | Output is correct |
49 | Correct | 149 ms | 157648 KB | Output is correct |
50 | Correct | 99 ms | 157648 KB | Output is correct |
51 | Correct | 118 ms | 157648 KB | Output is correct |
52 | Correct | 224 ms | 157648 KB | Output is correct |
53 | Correct | 163 ms | 157648 KB | Output is correct |
54 | Correct | 224 ms | 157648 KB | Output is correct |
55 | Runtime error | 313 ms | 263168 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
56 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 416 KB | Output is correct |
4 | Correct | 2 ms | 420 KB | Output is correct |
5 | Correct | 2 ms | 556 KB | Output is correct |
6 | Correct | 2 ms | 556 KB | Output is correct |
7 | Correct | 2 ms | 556 KB | Output is correct |
8 | Correct | 2 ms | 768 KB | Output is correct |
9 | Correct | 2 ms | 768 KB | Output is correct |
10 | Correct | 2 ms | 840 KB | Output is correct |
11 | Correct | 2 ms | 840 KB | Output is correct |
12 | Correct | 2 ms | 844 KB | Output is correct |
13 | Correct | 2 ms | 844 KB | Output is correct |
14 | Correct | 2 ms | 860 KB | Output is correct |
15 | Correct | 2 ms | 924 KB | Output is correct |
16 | Correct | 2 ms | 928 KB | Output is correct |
17 | Correct | 2 ms | 928 KB | Output is correct |
18 | Correct | 2 ms | 928 KB | Output is correct |
19 | Correct | 2 ms | 940 KB | Output is correct |
20 | Correct | 2 ms | 944 KB | Output is correct |
21 | Correct | 4 ms | 2740 KB | Output is correct |
22 | Correct | 3 ms | 3256 KB | Output is correct |
23 | Correct | 3 ms | 3256 KB | Output is correct |
24 | Correct | 7 ms | 4976 KB | Output is correct |
25 | Correct | 12 ms | 8196 KB | Output is correct |
26 | Correct | 12 ms | 9112 KB | Output is correct |
27 | Correct | 11 ms | 9112 KB | Output is correct |
28 | Correct | 12 ms | 9112 KB | Output is correct |
29 | Correct | 13 ms | 9304 KB | Output is correct |
30 | Correct | 7 ms | 9304 KB | Output is correct |
31 | Correct | 11 ms | 9304 KB | Output is correct |
32 | Correct | 8 ms | 9304 KB | Output is correct |
33 | Correct | 12 ms | 9524 KB | Output is correct |
34 | Correct | 13 ms | 9524 KB | Output is correct |
35 | Correct | 12 ms | 9524 KB | Output is correct |
36 | Correct | 7 ms | 9524 KB | Output is correct |
37 | Correct | 55 ms | 33092 KB | Output is correct |
38 | Correct | 49 ms | 33760 KB | Output is correct |
39 | Correct | 134 ms | 123116 KB | Output is correct |
40 | Correct | 106 ms | 123116 KB | Output is correct |
41 | Correct | 165 ms | 157648 KB | Output is correct |
42 | Correct | 91 ms | 157648 KB | Output is correct |
43 | Correct | 177 ms | 157648 KB | Output is correct |
44 | Correct | 170 ms | 157648 KB | Output is correct |
45 | Correct | 177 ms | 157648 KB | Output is correct |
46 | Correct | 76 ms | 157648 KB | Output is correct |
47 | Correct | 114 ms | 157648 KB | Output is correct |
48 | Correct | 174 ms | 157648 KB | Output is correct |
49 | Correct | 149 ms | 157648 KB | Output is correct |
50 | Correct | 99 ms | 157648 KB | Output is correct |
51 | Correct | 118 ms | 157648 KB | Output is correct |
52 | Correct | 224 ms | 157648 KB | Output is correct |
53 | Correct | 163 ms | 157648 KB | Output is correct |
54 | Correct | 224 ms | 157648 KB | Output is correct |
55 | Runtime error | 313 ms | 263168 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
56 | Halted | 0 ms | 0 KB | - |