Submission #35185

#TimeUsernameProblemLanguageResultExecution timeMemory
35185dqhungdlBootfall (IZhO17_bootfall)C++14
13 / 100
53 ms3396 KiB
#include <bits/stdc++.h> using namespace std; int n,sum,a[505],C[250005]; bool f[250005]; vector<int> rs; bool Special() { if(sum%2==1) return false; f[0]=true; for(int i=1;i<=n;i++) for(int j=a[i];j<=sum;j++) f[j]|=f[j-a[i]]; return f[sum/2]; } void Check(int pos) { for(int i=1;i<=sum-a[pos];i++) f[i]=false; for(int i=1;i<=n;i++) if(i!=pos) for(int j=sum-a[pos];j>=a[i];j--) f[j]|=f[j-a[i]]; for(int i=0;i<(sum-a[pos]+1)/2;i++) if(f[i]==true) C[sum-a[pos]-2*i]++; } int main() { ios_base::sync_with_stdio(false); //freopen("TEST.INP","r",stdin); cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; sum+=a[i]; } if(Special()==false) { cout<<0; return 0; } for(int i=1;i<=n;i++) Check(i); for(int i=1;i<=sum;i++) if(C[i]==n) rs.push_back(i); cout<<rs.size()<<"\n"; for(int i=0;i<rs.size();i++) cout<<rs[i]<<' '; }

Compilation message (stderr)

bootfall.cpp: In function 'int main()':
bootfall.cpp:53:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<rs.size();i++)
                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...