# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
342558 | katearima | Bootfall (IZhO17_bootfall) | C++14 | 460 ms | 3556 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N=505;
int n, a[N], sums[N*N+1], mx, num[N*N];
vector<int> ans;
void Add(int x){
mx+=x;
for(int j=mx; j>=x; j--){
sums[j]+=sums[j-x];
}
}
void Delete(int x){
for(int j=x; j<=mx; j++){
sums[j]-=sums[j-x];
}
mx-=x;
}
main(){
cin>>n;
sums[0]=1;
for(int i=0; i<n; i++){
cin>>a[i];
Add(a[i]);
}
if(sums[mx/2]==0){
cout<<"0"<<endl;
return 0;
}
for(int i=0; i<n; i++){
vector<bool> v(mx, false);
Delete(a[i]);
for(int j=0; j<=mx; j++){
if(sums[j]==0) continue;
int k=abs(mx-2*j);
if(!v[k]){
num[k]++;
v[k]=true;
}
}
Add(a[i]);
}
for(int i=0; i<=mx; i++){
if(num[i]==n) ans.push_back(i);
}
cout<<ans.size()<<endl;
for(int i=0; i<ans.size(); i++){
cout<<ans[i]<<" ";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |