#include<bits/stdc++.h>
using namespace std;
const int N = 100005;
int n;
long long A[N], B[N];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0); cin >> n;
for (int i = 1; i <= n; i++)
{
long double a, b;
cin >> a >> b;
A[i] = (int)(a * 10000);
B[i] = (int)(b * 10000);
}
sort(A + 1, A + n + 1);
sort(B + 1, B + n + 1);
reverse(A + 1, A + n + 1);
reverse(B + 1, B + n + 1);
for (int i = 1; i <= n; i++)
{
A[i] += A[i - 1];
B[i] += B[i - 1];
}
long long Mx = 0;
for (int k = 1; k <= n + n; k ++)
{
int l = 0, r = k, md;
if (k > n)
l = k - n, r = n;
while (r - l > 1)
{
md = (l + r) >> 1;
if (B[md] >= A[k - md])
r = md;
else
l = md;
}
for (int i = max(k - n, l - 2); i <= min(n, r + 2); i++)
Mx = max(Mx, min(B[i], A[k - i]) - k * 10000);
}
long double res = Mx; res /= (long double)(10000.0);
cout << fixed << setprecision(4) << res << endl;
return (0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |