# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
63262 | Tenuun | Bootfall (IZhO17_bootfall) | C++17 | 514 ms | 4288 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;
int sum=0;
int c[250001], res[250001];
void add(int t){
sum+=t;
for(int i=sum; i>=t; i--){
c[i]+=c[i-t];
}
}
void del(int t){
for(int i=t; i<=sum; i++){
c[i]-=c[i-t];
}
sum-=t;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
memset(c, 0, sizeof c);
memset(res, 0, sizeof res);
c[0]=1;
int n;
cin >> n;
int a[n];
for(int i=0; i<n; i++) {
cin >> a[i];
add(a[i]);
}
if(sum%2 || !c[sum/2]) return cout << 0, 0;
for(int i=0; i<n; i++){
del(a[i]);
for(int j=1; j<=sum; j++){
if((sum+j)%2) continue;
if(c[(sum+j)/2]) res[j]++;
}
add(a[i]);
}
vector<int> ans;
for(int i=1; i<=sum; i++){
if(res[i]==n) ans.push_back(i);
}
cout << ans.size() << endl;
for(int i=0; i<ans.size(); i++) cout << ans[i] << " ";
return 0;
}
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... |