This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
const int S=25001;
int sum[S+2],fre[S+2],t,New[S+1];
void inc(int x){
for(int j=S;j>=x;j--){
sum[j]+=sum[j-x];
}
return;
}
void dec(int x){
for(int j=0;j<=S-x;j++){
sum[j+x]-=sum[j];
}
return;
}
signed main()
{
int n;
cin>>n;
int arr[n];
sum[0]=1;
for(int i=0;i<n;i++){
cin>>arr[i];
inc(arr[i]);
t+=arr[i];
}
if(sum[t/2]==0){cout<<0<<endl;return 0;}
for(int i=0;i<n;i++){
dec(arr[i]);
t-=arr[i];
for(int j=0;j<=t-1;j++) {
if((t-j)-j>0&&sum[j]!=0&&sum[(t-j)]!=0) fre[(t-j)-j]++;
}
t+=arr[i];
inc(arr[i]);
}
int siz=0;
for(int j=1;j<=S;j++){
if(fre[j]==n) siz++;
}
cout<<siz<<endl;
for(int j=1;j<=S;j++){
if(fre[j]==n) cout<<j<<" ";
}
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... |