# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
969087 | TrendBattles | Gym Badges (NOI22_gymbadges) | C++14 | 115 ms | 15744 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.
//https://oj.uz/problem/view/NOI22_gymbadges
#include <bits/stdc++.h>
using namespace std;
using lli = int64_t;
#define INFILE "NOI22_gymbadges.inp"
#define OUTFILE "NOI22_gymbadges.out"
int main() {
ios::sync_with_stdio(0); cin.tie(0);
if (fopen(INFILE, "r")) {
freopen(INFILE, "r", stdin);
freopen(OUTFILE, "w", stdout);
}
int N; cin >> N;
vector <int> X(N), L(N);
for (int& v : X) cin >> v;
for (int& v : L) cin >> v;
vector <int> order(N); iota(order.begin(), order.end(), 0);
sort(order.begin(), order.end(), [&] (int u, int v) {
return L[u] < L[v];
});
int max_participated = 0;
priority_queue <int> heap; lli sum = 0;
for (int i = 0; i < N; ++i) {
while (sum > L[order[i]]) {
sum -= heap.top();
heap.pop();
}
heap.emplace(X[order[i]]);
sum += X[order[i]];
max_participated = max(max_participated, (int) heap.size());
}
cout << max_participated;
return 0;
}
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... |