Submission #700078

#TimeUsernameProblemLanguageResultExecution timeMemory
700078fdnfksdBootfall (IZhO17_bootfall)C++14
100 / 100
620 ms3444 KiB
#include<bits/stdc++.h> #define TASKNAME "bieudo" #define pb push_back #define pli pair<int,int> #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); using namespace std; using ll=int; const ll maxN=600; const ll mod=1e9+19972207; ll dp[505*505]; ll cnt[505*505]={0}; ll n,a[maxN]; void solve() { cin >> n; ll m=0; for(int i=1;i<=n;i++) cin >> a[i],m+=a[i]; dp[0]=1; for(int i=1;i<=n;i++) { for(int j=m;j>=a[i];j--) { dp[j]+=dp[j-a[i]]; if(dp[j]>=mod) dp[j]-=mod; //dp2[j]+=dp2[j-a[i]]; //if(dp2[j]>=mod2) dp2[j]-=mod2; } } if(m%2!=0) { cout << 0; return; } ll x=m/2; if(dp[x]==0) { cout << 0; return; } for(int i=1;i<=n;i++) { for(int j=a[i];j<=m;j++) { dp[j]-=dp[j-a[i]]; if(dp[j]<0) dp[j]+=mod; } for(int j=0;j<=(m-a[i])/2;j++) { if(dp[j]>0) { cnt[m-j-a[i]-j]++; } } for(int j=m;j>=a[i];j--) { dp[j]+=dp[j-a[i]]; if(dp[j]>=mod) dp[j]-=mod; } } vector<ll> ans; for(int i=1;i<=m;i++) { if(cnt[i]==n) { ans.pb(i); } } cout <<ans.size()<<'\n'; for(auto zz:ans) cout << zz <<' '; } int main() { fastio //freopen(TASKNAME".INP","r",stdin); //freopen(TASKNAME".OUT","w",stdout); solve(); }
#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...