Submission #724114

#TimeUsernameProblemLanguageResultExecution timeMemory
724114DenkataBootfall (IZhO17_bootfall)C++14
0 / 100
1 ms340 KiB
#include<bits/stdc++.h> using namespace std; const int maxn = 503; bitset <250006> ans; bitset <250006> tek; bitset <250006> newtek; int i,j,p,q,n,m,k,sum; int a[maxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>n; for(i=1; i<=n; i++) { cin>>a[i]; sum+=a[i]; } for(i=2;i<=n;i++) { if(a[i]%2!=a[i-1]%2) { cout<<0<<endl; return 0; } } for(i=0;i<=sum;i++) ans[i]=1; tek.set(0); for(i=1;i<=n;i++) { ///bez i tek[0]=1; for(j=1;j<=n;j++) { if(j==i)continue; tek|=(tek<<(2*a[j])); } tek=(tek<<(a[i])); for(j=0;j<=sum;j++) ans[j]=ans[j]&tek[j],tek[j]=0; } int br = 0; for(i=0;i<sum;i++) if(ans[i])br++; cout<<br<<endl; for(i=sum-1;i>=0;i--) { if(ans[i]) cout<<sum-i<<" "; } return 0; } /** 4 1 3 1 5 */
#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...