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 dbl = double;
int main() {
int n;
cin >> n;
vector <pair <dbl, dbl>> nums(n);
for (int i = 0; i < n; i++)
cin >> nums[i].first >> nums[i].second;
vector <dbl> a(n), b(n);
for (int i = 0; i < n; i++) {
a[i] = nums[i].first;
b[i] = nums[i].second;
}
sort(a.begin(), a.end());
sort(b.begin(), b.end());
dbl l = a.back(), r = b.back();
dbl ans = max((dbl)0, min(l, r) - (dbl)2);
for (int cnt = 4, pt = n-2; cnt <= n*2; cnt += 2, pt--) {
if (r - l > 0.000000001)
l += a[pt];
else
r += b[pt];
ans = max(ans, min(l, r) - (cnt - 1));
if (r - l > 0.0000000001)
r += b[pt];
else
l += a[pt];
ans = max(ans, min(l, r) - cnt);
}
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... |