Submission #877466

#TimeUsernameProblemLanguageResultExecution timeMemory
877466princeBootfall (IZhO17_bootfall)C++17
0 / 100
323 ms460 KiB
#include "bits/stdc++.h" using namespace std; using ll = long long; ll rec(int n,vector<int>&vec,int sum1,int sum2){ if(n==0){ return abs(sum1-sum2); } int a=rec(n-1,vec,sum1+vec[n-1],sum2); int b=rec(n-1,vec,sum1,sum2+vec[n-1]); return min(a,b); } void solve(){ int n;cin>>n; vector<int>vec(n); set<int>st; sort(vec.begin(),vec.end()); if(n%2&&vec[0]==vec[vec.size()-1]){ cout<<0; return; } for(auto &x:vec)cin>>x; for(ll i=0;i<n;i++){ for(ll j=1;j<=9e2;j++){ bool check=1; for(ll k=0;k<n;k++){ ll l=vec[k]; vec[k]=j; //cout<<l<<" "; ll ans=rec(n,vec,0,0); vec[k]=l; if(ans!=0){ check=0; break; } } if(check){ //cout<<j<<" "; st.insert(j); } } } cout<<st.size()<<endl; for(auto &x:st)cout<<x<<" "; } signed main() { cin.tie(0)->sync_with_stdio(false); #ifdef prince freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int q = 1; // cin >> q; while (q--) { solve(); cout << '\n'; } }
#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...