Submission #598059

#TimeUsernameProblemLanguageResultExecution timeMemory
598059SummersBootfall (IZhO17_bootfall)C++14
100 / 100
339 ms4836 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; long long a[1000000], s[1000000]={1}, ans[250001]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long i,j,n,last=0,br=0; cin>>n; for(i=1;i<=n;i++) { cin>>a[i]; for(j=last;j>=0;j--) { if(s[j])s[j+a[i]]+=s[j]; } last+=a[i]; } if(s[last/2]==0 || last%2!=0){cout<<0<<endl;return 0;} for(i=1;i<=n;i++) { last-=a[i]; for(j=0;j<=last;j++) { if(s[j])s[j+a[i]]-=s[j]; } for(j=1;j<=250000;j++) { if((last+j)%2!=0 || s[(last+j)/2]==0) { if(ans[j]==0)br++; ans[j]=1; } } for(j=last;j>=0;j--) { if(s[j])s[j+a[i]]+=s[j]; } last+=a[i]; } cout<<250000-br<<endl; for(i=1;i<=250000;i++) { if(ans[i]==0)cout<<i<<" "; } cout<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...