Submission #886521

#TimeUsernameProblemLanguageResultExecution timeMemory
886521okaragulGym Badges (NOI22_gymbadges)C++17
0 / 100
328 ms17492 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl "\n" #define all(aa) aa.begin(), aa.end() int main(){ ll n; cin>>n; vector<ll> a(n), b(n), x(n); for(auto &e:a) cin>>e; for(auto &e:b) cin>>e; iota(all(x), 0); sort(all(x), [&](ll l, ll r){ return (b[l]-a[r]<min({b[l], b[r], b[r]-a[l]})); }); int ans=0; for(int mask=0; mask<(1<<n); mask++){ bool f=1; ll cur=0; for(ll i=0; i<n; i++){ if(mask&(1<<i)){ if(cur<=b[i]){ cur+=a[i]; } else{ f=0; break; } } } if(f) ans=max(ans, __builtin_popcount(mask)); } cout<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...