#include <bits/stdc++.h>
using namespace std;
using ll = long long;
/*
* max(min(Sum_{1 to n} of ai or -1,
* Sum_{1 to n} of bi or -1))
*
*/
const int maxn = 1e5+5;
int n;
double a[maxn], b[maxn];
int main()
{
//ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i] >> b[i];
}
sort(a+1,a+1+n,greater<double>());
sort(b+1,b+1+n,greater<double>());
for (int i = 1; i <= n; i++) {
a[i] += a[i-1] - 1;
b[i] += b[i-1] - 1;
//cout << a[i] << ' ' << b[i] << '\n';
}
double maxans = 0;
for (int i = 0; i <= n; i++) {
int lo = 0, hi = n;
while (lo < hi) {
int mid = (lo+hi)/2;
int aa = a[i] - mid;
int bb = b[mid] - i;
if (bb <= aa) {
lo = mid+1;
}
else {
hi = mid-1;
}
}
for (int j = max(0,hi-1); j <= min(n,hi+1); j++) {
maxans = max(maxans,min(a[i]-j,b[j]-i));
}
}
printf("%.4lf\n",(double)maxans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
135 ms |
1940 KB |
Output is correct |
18 |
Correct |
139 ms |
1920 KB |
Output is correct |
19 |
Correct |
133 ms |
1848 KB |
Output is correct |
20 |
Correct |
134 ms |
1912 KB |
Output is correct |
21 |
Correct |
150 ms |
1892 KB |
Output is correct |
22 |
Correct |
132 ms |
1960 KB |
Output is correct |
23 |
Correct |
132 ms |
1912 KB |
Output is correct |
24 |
Correct |
134 ms |
1912 KB |
Output is correct |
25 |
Correct |
134 ms |
1824 KB |
Output is correct |
26 |
Correct |
159 ms |
1896 KB |
Output is correct |