# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
671176 | irmuun | Bootfall (IZhO17_bootfall) | C++17 | 1100 ms | 123084 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;
#define ll long long
#define pb push_back
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n;
cin>>n;
int a[n+5];
int sum=0;
for(int i=1;i<=n;i++){
cin>>a[i];
sum+=a[i];
}
sort(a+1,a+n+1);
int dp[n+5][500*n+5];
for(int i=0;i<=n;i++){
fill(dp[i],dp[i]+500*n+1,0);
dp[i][0]=1;
int cur=0;
for(int j=1;j<=n;j++){
if(i==j){
continue;
}
for(int k=cur;k>=0;k--){
if(dp[i][k]==1){
dp[i][k+a[j]]=1;
}
}
cur+=a[j];
}
}
vector<int>ans;
for(int i=1;i<=sum;i++){
bool ok=true;
for(int j=0;j<=n;j++){
if(j==0){
if(sum%2==1){
ok=false;
break;
}
if(dp[j][sum/2]==0){
ok=false;
break;
}
}
else{
if((sum+i-a[j])%2==1){
ok=false;
break;
}
if(dp[j][(sum+i-a[j])/2]==0){
ok=false;
break;
}
}
}
if(ok==true){
ans.pb(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... |