Submission #886522

#TimeUsernameProblemLanguageResultExecution timeMemory
886522vjudge1Gym Badges (NOI22_gymbadges)C++17
15 / 100
2012 ms9672 KiB
#include <bits/stdc++.h> using namespace std; #define tol(bi) (1ll<<((int)(bi))) int main(){ int n; cin>>n; vector<pair<int,int>> arr(n); for (int i = 0; i < n; ++i) { cin>>arr[i].second; } for (int i = 0; i < n; ++i) { cin>>arr[i].first; } sort(arr.begin(), arr.end(), [&](pair<int,int> a, pair<int,int> b){ return (a.first+a.second)<(b.first+b.second); }); int ans = 0; for (int bas = 0; bas < n; bas++){ int crr = 0; int somma = 0; for (int i = bas; i < n; i++){ if (somma>arr[i].first) continue; somma+=arr[i].second; crr++; } ans=max(ans,crr); } 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...