Submission #757979

#TimeUsernameProblemLanguageResultExecution timeMemory
757979roCatalystGym Badges (NOI22_gymbadges)C++14
24 / 100
406 ms5544 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { int N; cin >> N; vector<int> X; for (int i = 0; i < N; i++) { int Xi; cin >> Xi; X.push_back(Xi); } vector<int> L; for (int i = 0; i < N; i++) { int Li; cin >> Li; L.push_back(Li); } if (N > 10) { int ans = 0; sort(X.begin(),X.end()); ll currLevel = 0; ll cap = L.back(); vector<int>::iterator p = X.begin(); while ((currLevel <= cap)&&(p!=X.end())) { ans++; currLevel += *p; p++; } cout << ans << endl; } else { int ans = 0; vector<int> perm; for (int i = 0; i < N; i++) { perm.push_back(i); } do { int currAns = 0; ll currLevel = 0; for(auto p = perm.begin(); p != perm.end(); p++) { if (currLevel > L[*p]) { break; } else { currAns++; currLevel += X[*p]; } } ans = max(currAns,ans); } while(next_permutation(perm.begin(),perm.end())); 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...