#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 |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |