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 ll = long long;
int main() {
int n;
cin >> n;
vector <pair <ll, ll>> nums(n);
for (int i = 0; i < n; i++) {
double a, b;
cin >> a >> b;
nums[i].first = (a * 10000);
nums[i].second = (b * 10000);
}
vector <ll> 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());
ll l = a.back(), r = b.back();
ll ans = max(0LL, min(l, r) - 20000);
for (int cnt = 4, pt = n-2; cnt <= n*2; cnt += 2, pt--) {
bool chosen = false;
if (l < r) {
l += a[pt];
chosen = true;
}
else
r += b[pt];
ans = max(ans, min(l, r) - (cnt-1) * 10000);
if (chosen)
r += b[pt];
else
l += a[pt];
ans = max(ans, min(l, r) - cnt * 10000);
}
cout << fixed << setprecision(4) << (double)ans / 10000 << '\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... |