Submission #878938

#TimeUsernameProblemLanguageResultExecution timeMemory
878938heeheeheehaawBootfall (IZhO17_bootfall)C++17
100 / 100
764 ms2560 KiB
#include <bits/stdc++.h> using namespace std; bitset<125005> dp; int v[505], sepoate[250005]; int main() { int n, sum = 0; cin>>n; dp[0] = 1; for(int i = 1; i <= n; i++) { cin>>v[i], sum += v[i]; dp = ((dp << v[i]) | dp); } if(sum % 2 == 1 || dp[sum / 2] == 0) { cout<<0; return 0; } for(int i = 1; i <= n; i++) { dp.reset(); sum -= v[i]; dp[0] = 1; for(int j = 1; j <= n; j++) { if(j == i) continue; dp |= (dp << v[j]); } for(int j = 0; j <= sum && j * 2 <= sum; j++) if(dp[j] == 1) sepoate[sum - 2 * j]++; sum += v[i]; } int rez = 0; vector<int> aux; for(int i = 0; i <= sum; i++) if(sepoate[i] == n) rez++, aux.push_back(i); cout<<rez<<'\n'; for(auto it : aux) cout<<it<<" "; 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...