# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
91229 | 2018-12-26T15:23:55 Z | Vardanyan | Bootfall (IZhO17_bootfall) | C++14 | 3 ms | 1248 KB |
#include<bits/stdc++.h> using namespace std; const int N = 505; char dp[N][N*N*2]; int a[N]; int dp1[N*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]; } 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]>0); for(int s = 2*MX;s>=0;s--) dp1[s+a[i]] += dp1[s]; } //cout<<sum<<endl; //cout<<dp[0][sum/2]<<endl; 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 && 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 | 452 KB | Output is correct |
3 | Correct | 2 ms | 588 KB | Output is correct |
4 | Correct | 2 ms | 588 KB | Output is correct |
5 | Correct | 2 ms | 660 KB | Output is correct |
6 | Correct | 2 ms | 660 KB | Output is correct |
7 | Correct | 2 ms | 660 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 | 452 KB | Output is correct |
3 | Correct | 2 ms | 588 KB | Output is correct |
4 | Correct | 2 ms | 588 KB | Output is correct |
5 | Correct | 2 ms | 660 KB | Output is correct |
6 | Correct | 2 ms | 660 KB | Output is correct |
7 | Correct | 2 ms | 660 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 | 736 KB | Output is correct |
11 | Correct | 2 ms | 736 KB | Output is correct |
12 | Correct | 2 ms | 736 KB | Output is correct |
13 | Correct | 2 ms | 736 KB | Output is correct |
14 | Correct | 2 ms | 736 KB | Output is correct |
15 | Correct | 2 ms | 736 KB | Output is correct |
16 | Correct | 2 ms | 736 KB | Output is correct |
17 | Correct | 2 ms | 736 KB | Output is correct |
18 | Correct | 2 ms | 736 KB | Output is correct |
19 | Correct | 2 ms | 736 KB | Output is correct |
20 | Correct | 2 ms | 736 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 452 KB | Output is correct |
3 | Correct | 2 ms | 588 KB | Output is correct |
4 | Correct | 2 ms | 588 KB | Output is correct |
5 | Correct | 2 ms | 660 KB | Output is correct |
6 | Correct | 2 ms | 660 KB | Output is correct |
7 | Correct | 2 ms | 660 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 | 736 KB | Output is correct |
11 | Correct | 2 ms | 736 KB | Output is correct |
12 | Correct | 2 ms | 736 KB | Output is correct |
13 | Correct | 2 ms | 736 KB | Output is correct |
14 | Correct | 2 ms | 736 KB | Output is correct |
15 | Correct | 2 ms | 736 KB | Output is correct |
16 | Correct | 2 ms | 736 KB | Output is correct |
17 | Correct | 2 ms | 736 KB | Output is correct |
18 | Correct | 2 ms | 736 KB | Output is correct |
19 | Correct | 2 ms | 736 KB | Output is correct |
20 | Correct | 2 ms | 736 KB | Output is correct |
21 | Incorrect | 3 ms | 1248 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 452 KB | Output is correct |
3 | Correct | 2 ms | 588 KB | Output is correct |
4 | Correct | 2 ms | 588 KB | Output is correct |
5 | Correct | 2 ms | 660 KB | Output is correct |
6 | Correct | 2 ms | 660 KB | Output is correct |
7 | Correct | 2 ms | 660 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 | 736 KB | Output is correct |
11 | Correct | 2 ms | 736 KB | Output is correct |
12 | Correct | 2 ms | 736 KB | Output is correct |
13 | Correct | 2 ms | 736 KB | Output is correct |
14 | Correct | 2 ms | 736 KB | Output is correct |
15 | Correct | 2 ms | 736 KB | Output is correct |
16 | Correct | 2 ms | 736 KB | Output is correct |
17 | Correct | 2 ms | 736 KB | Output is correct |
18 | Correct | 2 ms | 736 KB | Output is correct |
19 | Correct | 2 ms | 736 KB | Output is correct |
20 | Correct | 2 ms | 736 KB | Output is correct |
21 | Incorrect | 3 ms | 1248 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 452 KB | Output is correct |
3 | Correct | 2 ms | 588 KB | Output is correct |
4 | Correct | 2 ms | 588 KB | Output is correct |
5 | Correct | 2 ms | 660 KB | Output is correct |
6 | Correct | 2 ms | 660 KB | Output is correct |
7 | Correct | 2 ms | 660 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 | 736 KB | Output is correct |
11 | Correct | 2 ms | 736 KB | Output is correct |
12 | Correct | 2 ms | 736 KB | Output is correct |
13 | Correct | 2 ms | 736 KB | Output is correct |
14 | Correct | 2 ms | 736 KB | Output is correct |
15 | Correct | 2 ms | 736 KB | Output is correct |
16 | Correct | 2 ms | 736 KB | Output is correct |
17 | Correct | 2 ms | 736 KB | Output is correct |
18 | Correct | 2 ms | 736 KB | Output is correct |
19 | Correct | 2 ms | 736 KB | Output is correct |
20 | Correct | 2 ms | 736 KB | Output is correct |
21 | Incorrect | 3 ms | 1248 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 452 KB | Output is correct |
3 | Correct | 2 ms | 588 KB | Output is correct |
4 | Correct | 2 ms | 588 KB | Output is correct |
5 | Correct | 2 ms | 660 KB | Output is correct |
6 | Correct | 2 ms | 660 KB | Output is correct |
7 | Correct | 2 ms | 660 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 | 736 KB | Output is correct |
11 | Correct | 2 ms | 736 KB | Output is correct |
12 | Correct | 2 ms | 736 KB | Output is correct |
13 | Correct | 2 ms | 736 KB | Output is correct |
14 | Correct | 2 ms | 736 KB | Output is correct |
15 | Correct | 2 ms | 736 KB | Output is correct |
16 | Correct | 2 ms | 736 KB | Output is correct |
17 | Correct | 2 ms | 736 KB | Output is correct |
18 | Correct | 2 ms | 736 KB | Output is correct |
19 | Correct | 2 ms | 736 KB | Output is correct |
20 | Correct | 2 ms | 736 KB | Output is correct |
21 | Incorrect | 3 ms | 1248 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |