#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <iomanip>
const double EPS = 1e-9;
int main(){
int n;
std::cin >> n;
std::vector<double> a = {0.0}, b = {0.0};
for(int i = 0; i < n; i++){
double x, y;
std::cin >> x >> y;
a.push_back(x - 1.0);
b.push_back(y - 1.0);
}
sort(a.rbegin(), a.rend() - 1);
sort(b.rbegin(), b.rend() - 1);
for(int i = 1; i <= n; ++i) {
a[i] += a[i - 1];
b[i] += b[i - 1];
}
double ans = 0.0;
for(int k = 0; k < 2; ++k) {
for(int i = 0; i <= n; ++i) {
int lo = 1, hi = std::min(n, static_cast<int>(a[i])), best_j = 0;
while(lo <= hi) {
int j = (lo + hi) / 2;
if( a[i] - j <= b[j] - i + EPS ) {
hi = j - 1;
best_j = j;
} else {
lo = j + 1;
}
}
ans = std::max(ans, std::min(a[i] - best_j, b[best_j] - i));
}
swap(a, b);
}
std::cout << std::fixed << std::setprecision(4) << ans << std::endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
304 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
212 KB |
Output is correct |
13 |
Correct |
2 ms |
316 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
312 KB |
Output is correct |
16 |
Correct |
2 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
304 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
212 KB |
Output is correct |
13 |
Correct |
2 ms |
316 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
312 KB |
Output is correct |
16 |
Correct |
2 ms |
212 KB |
Output is correct |
17 |
Correct |
134 ms |
3440 KB |
Output is correct |
18 |
Correct |
129 ms |
3384 KB |
Output is correct |
19 |
Correct |
132 ms |
3412 KB |
Output is correct |
20 |
Correct |
131 ms |
3396 KB |
Output is correct |
21 |
Correct |
152 ms |
3732 KB |
Output is correct |
22 |
Correct |
128 ms |
3436 KB |
Output is correct |
23 |
Correct |
130 ms |
3396 KB |
Output is correct |
24 |
Correct |
132 ms |
3444 KB |
Output is correct |
25 |
Correct |
130 ms |
3352 KB |
Output is correct |
26 |
Correct |
152 ms |
3916 KB |
Output is correct |