이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<pair<int, int>> gyms(n);
for (int i = 0; i < n; i++) {
cin >> gyms[i].second;
}
for (int i = 0; i < n; i++) {
cin >> gyms[i].first;
}
sort(gyms.begin(), gyms.end());
long long level = 0;
int ans = 0;
priority_queue<long long> pq;
for (int i = 0; i < n; i++) {
if (level <= gyms[i].first) {
level += gyms[i].second;
pq.push(gyms[i].second);
ans++;
}
else {
long long x = pq.top();
if (level-x <= gyms[i].first && x >= gyms[i].second) {
pq.pop();
pq.push(gyms[i].second);
level -= x;
level += gyms[i].second;
}
}
}
cout << ans << '\n';
return 0;
}
# | 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... |