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 pii pair<int,int>
#define OK puts("OK");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define pb push_back
#define endi puts("");
const int N = 1e6+12,INF=1e9+7;
int a[N],b[N],q[N],dp[N],n,sum;
int used[N];
void add(int x){
int i;
for (i=sum;i>=0;--i){
dp[i+x]+=dp[i];
}
ret ;
}
void del(int x){
int i;
for (i=0;i<=sum;++i){
dp[i+x]-=dp[i];
}
ret ;
}
main(){
int i,j,x;
scan1(n)
dp[0]=1;
for (i=1;i<=n;++i){
scan1(q[i])
add(q[i]);
sum+=q[i];
}
if(sum&1 || !dp[sum/2]){
cout << 0 << endl;
return 0;
}
for (i=1;i<=n;++i){
del(q[i]);
sum-=q[i];
for (j=sum/2;j<=sum;++j){
if (dp[j] && j*2 > sum)
used[j*2-sum]++;
}
sum+=q[i];
add(q[i]);
}
vector <int> ans;
for (x=1;x<=sum;++x){
if (used[x]==n)ans.pb(x);
}
cout <<ans.size()<<"\n";
for (i=0;i<ans.size();++i){
cout <<ans[i]<<" ";
}
}
Compilation message (stderr)
bootfall.cpp:34:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
34 | main(){
| ^~~~
bootfall.cpp: In function 'int main()':
bootfall.cpp:65:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
65 | for (i=0;i<ans.size();++i){
| ~^~~~~~~~~~~
bootfall.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
9 | #define scan1(a) scanf("%lld",&a);
| ~~~~~^~~~~~~~~~~
bootfall.cpp:36:5: note: in expansion of macro 'scan1'
36 | scan1(n)
| ^~~~~
bootfall.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
9 | #define scan1(a) scanf("%lld",&a);
| ~~~~~^~~~~~~~~~~
bootfall.cpp:39:9: note: in expansion of macro 'scan1'
39 | scan1(q[i])
| ^~~~~
# | 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... |