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