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;
using db = double;
int32_t main() {
int n;
cin >> n;
vector<db> a(n), b(n);
db ans = 0, sa = 0, sb = 0;
for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
sort(a.rbegin(), a.rend());
sort(b.rbegin(), b.rend());
int pa = 0, pb = 0;
for (int i = 1; i <= 2 * n; i++) {
if (sa <= sb && pa < n) sa += a[pa++];
else if (sb <= sa && pb < n) sb += b[pb++];
ans = max(ans, min(sa, sb) - i);
}
cout << fixed << setprecision(4) << ans << '\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... |