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>
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... |