# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
36794 | 2017-12-14T17:44:51 Z | top34051 | Bootfall (IZhO17_bootfall) | C++14 | 3 ms | 4956 KB |
#include<bits/stdc++.h> using namespace std; const int maxn = 305; const int mx = 150000; int n; int a[maxn], cnt[mx+505]; long long dp[mx+505], temp[mx+505]; vector<int> ans; int main() { scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]); int sum = 0; for(int i=1;i<=n;i++) sum += a[i]; dp[0] = 1; for(int i=1;i<=n;i++) { for(int x=mx;x>=0;x--) dp[x+a[i]] += dp[x]; // for(int x=0;x<=mx;x++) printf("%lld ",dp[x]); // printf("\n"); } if(sum%2!=0 || dp[sum/2]==0) return !printf("0"); for(int i=1;i<=n;i++) { memset(temp,0,sizeof(temp)); for(int x=0;x<=mx;x++) { temp[x] += dp[x]; temp[x+a[i]] -= temp[x]; } // printf("%d : ",i); for(int x=0;x<=mx;x++) { // printf("%d ",temp[x]); if((sum-a[i]+x)%2==0 && temp[(sum-a[i]-x)/2]!=0) cnt[x]++; } // printf("\n"); } for(int i=1;i<=mx;i++) if(cnt[i]==n) ans.push_back(i); printf("%d\n",ans.size()); for(auto x : ans) printf("%d ",x); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 4956 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 4956 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 4956 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 4956 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 4956 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 4956 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |