#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long, long long>
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
const ll N = 2e5 + 100;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll block = 480;
double a[N], b[N];
ll n;
void to_thic_cau(){
cin >> n;
for(int i = 1; i <= n;i++) cin >> a[i] >> b[i];
sort(a + 1, a + n + 1); reverse(a + 1, a + n + 1);
sort(b + 1, b + n + 1); reverse(b + 1, b + n + 1);
for(int i = 1; i <= n;i++) a[i] += a[i-1];
for(int i = 1; i <= n;i++) b[i] += b[i-1];
double res = -inf;
for(int i = 0; i <= n;i++){
ll l = 1, r = n, pos = -1;
while(l <= r){
ll mid = (l + r) / 2;
if(b[pos] >= a[i]){
pos = mid;
r = mid - 1;
}
else l = mid + 1;
}
if(pos == -1) continue;
res = max(res, min(a[i], b[pos]) - 1.00 * (i + pos));
}
for(int i = 0; i <= n;i++){
ll l = 1, r = n, pos = -1;
while(l <= r){
ll mid = (l + r) / 2;
if(a[pos] >= b[i]){
pos = mid;
r = mid - 1;
}
else l = mid + 1;
}
if(pos == -1) continue;
res = max(res, min(b[i], a[pos]) - 1.00 * (i + pos));
}
cout << fixed << setprecision(4) << res << '\n';
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
ll tc = 1;
//cin >> tc;
while(tc--) to_thic_cau();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |