Submission #766770

#TimeUsernameProblemLanguageResultExecution timeMemory
766770TrunktyBootfall (IZhO17_bootfall)C++14
28 / 100
1088 ms2532 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define int ll int n,tot,mod=1e9+7; int arr[505],dp[250005]; signed main(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> n; for(int i=1;i<=n;i++){ cin >> arr[i]; tot += arr[i]; } dp[0] = 1; for(int i=1;i<=n;i++){ for(int j=250000;j>=arr[i];j--){ dp[j] += dp[j-arr[i]]; dp[j] %= mod; } } if(tot%2 or dp[tot/2]==0){ cout << 0 << "\n"; cout << "\n"; return 0; } vector<int> ans; for(int i=1;i<=250000;i++){ bool yes = true; for(int j=1;j<=n;j++){ if((tot-arr[j]+i)%2){ yes = false; break; } int x = (tot-arr[j]+i)/2; if(!dp[x]){ yes = false; break; } int c1=0,c2=0; for(int k=x;k>=0;k-=arr[j]){ c1 += dp[k]; swap(c1,c2); } if(c1%mod==c2%mod){ yes = false; break; } } if(yes){ ans.push_back(i); } } cout << ans.size() << "\n"; for(int i:ans){ cout << i << " "; } cout << "\n"; return 0; }
#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...