# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
886523 | Kel_Mahmut | Gym Badges (NOI22_gymbadges) | C++14 | 351 ms | 27452 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define pb push_back
#define all(aa) aa.begin(), aa.end()
using namespace std;
typedef long long ll;
int main(){
int n;
cin >> n;
vector<ll> L(n), X(n);
for(int i = 0; i < n; i++)
cin >> X[i];
for(int i = 0; i < n; i++)
cin >> L[i];
vector<pair<ll, ll>> G(n);
for(int i = 0; i < n; i++){
G[i] = make_pair(L[i], X[i]);
}
sort(all(G));
priority_queue<ll> vals;
ll score = 0, ans = 0;
for(int i = 0; i < n; i++){
auto [Li, Xi] = G[i];
if(score <= Li){
vals.push(Xi);
score += Xi;
ans++;
}
else if(vals.top() > Xi){
score -= vals.top(); vals.pop();
score += Xi; vals.push(Xi);
}
}
cout << ans << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |