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 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 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... |