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;
#define int long long
#define OYY LLONG_MAX
#define mod 998244353
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR for(int i=1;i<=n;i++)
#define mid (start+end)/2
#define lim 250005
#define fi first
#define se second
int dp[lim];
int cev[lim];
int sum;
int32_t main(){
faster
int n;cin>>n;
int dizi[n];
FOR{
cin>>dizi[i];
sum+=dizi[i];
}
dp[0]=1;
FOR{
for(int j=sum;j>=dizi[i];j--){
dp[j]+=dp[j-dizi[i]];
}
}
if(sum&1 || dp[sum/2]==0){
cout<<0<<'\n';
return 0;
}
FOR{
for(int j=dizi[i];j<=sum;j++){
dp[j]-=dp[j-dizi[i]];
}
for(int j=1;j<=sum;j++){
int cur_sum=sum-dizi[i]+j;
if(cur_sum%2==0 && dp[cur_sum/2])cev[j]++;
}
for(int j=sum;j>=dizi[i];j--){
dp[j]+=dp[j-dizi[i]];
}
}
vector<int> cevv;
for(int i=1;i<=sum;i++){
if(cev[i]==n)cevv.push_back(i);
}
cout<<cevv.size()<<'\n';
for(auto x:cevv){
cout<<x<<" ";
}
cout<<'\n';
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... |