이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 100'000 + 10;
int n;
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n;
priority_queue<double> qa, qb;
while (n--) {
double a, b; cin >> a >> b;
qa.push(a); qb.push(b);
}
double first = 0, second = 0, answer = 0;
int cnt = 0;
while (true) {
if (first <= second && qa.size()) {
first += qa.top(); qa.pop();
cnt += 1;
} else if (second <= first && qb.size()) {
second += qb.top(); qb.pop();
cnt += 1;
} else break;
answer = max(answer, min(first, second) - cnt);
}
cout << setprecision(4) << fixed << answer << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |