#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)1e5 + 7;
const int infint = (int)1e9;
int n;
ld a[MAXN], b[MAXN];
ld g(int mid, int ted)
{
ld c1 = 0;
if(mid)
c1 = a[mid - 1];
mid = ted - mid;
ld c2 = 0;
if(mid)
c2 = b[mid - 1];
return min(c1, c2);
}
ld f(int ted)
{
//jelo tarin i ro mikhaim ke g(i) > g(i - 1)
int L = 0, R = ted + 1;
while(R - L > 1)
{
int mid = (R + L) >> 1;
if(g(mid, ted) > g(mid - 1, ted))
L = mid;
else
R = mid;
}
return g(L, ted);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i] >> b[i];
sort(a, a + n);
sort(b, b + n);
reverse(a, a + n);
reverse(b, b + n);
for (int i = 1; i < n; i++)
a[i] += a[i - 1], b[i] += b[i - 1];
ld ans = 0;
for (int i = 1; i <= n; i++)
ans = max(ans, f(i) - i);
cout << fixed << setprecision(4) << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
512 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 |
512 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 |
512 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |