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;
bitset<125005> dp;
int v[505], sepoate[250005];
int main()
{
int n, sum = 0;
cin>>n;
dp[0] = 1;
for(int i = 1; i <= n; i++)
{
cin>>v[i], sum += v[i];
dp = ((dp << v[i]) | dp);
}
if(sum % 2 == 1 || dp[sum / 2] == 0)
{
cout<<0;
return 0;
}
for(int i = 1; i <= n; i++)
{
dp.reset();
sum -= v[i];
dp[0] = 1;
for(int j = 1; j <= n; j++)
{
if(j == i) continue;
dp = ((dp << v[j]) | dp);
}
for(int j = 0; j <= sum && j * 2 <= sum; j++)
if(dp[j] == 1)
sepoate[sum - 2 * j]++;
sum += v[i];
}
int rez = 0;
vector<int> aux;
for(int i = 0; i <= sum; i++)
if(sepoate[i] == n)
rez++, aux.push_back(i);
cout<<rez<<'\n';
for(auto it : aux) cout<<it<<" ";
return 0;
}
# | 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... |