Submission #930701

#TimeUsernameProblemLanguageResultExecution timeMemory
930701allin27xBootfall (IZhO17_bootfall)C++17
65 / 100
1084 ms3664 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 502; int g[MAXN*MAXN]; int ar[MAXN]; int n; bitset<MAXN * MAXN> kp; void knap(int ind){ kp.reset(); kp.set(0); int s =0; for (int i=0; i<n; i++) if (i!= ind) s+=ar[i]; for (int i=0; i<n; i++){ if (i==ind) continue; kp |= kp<<ar[i]; } for (int i=1; i<n*MAXN; i++){ if (!kp[i]) continue; if (2*i-s <= 0) continue; g[2*i-s] ++; } } int main(){ cin>>n; for (int i=0; i<n; i++) cin>>ar[i]; if (n&1) {cout<<0; exit(0);} int s=0; for (int i=0; i<n; i++) s += ar[i]; kp.set(0); for (int i=0; i<n; i++){ kp |= kp << ar[i]; } if (!kp[s/2]) {cout<<0; exit(0);} for (int i=0; i<n; i++){ knap(i); } set<int> good; for (int i=1; i<MAXN*MAXN; i++) if (g[i] == n) good.insert(i); cout<<good.size()<<'\n'; for (int x: good) cout<<x<<' '; }
#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...