# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1136456 | concua | Mobile (BOI12_mobile) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 1;
pair<double, double> p[N];
int n, L;
double pre = 0.0;
bool check(double x){
pre = 0.0;
for (int i = 1; i <= n; i++){
if (x * x < p[i].second * p[i].second{
return false;
}
double delta = sqrt(x * x - p[i].second * p[i].second);
if (pre > p[i].first - delta){
pre = max(pre, p[i].first + delta);
}
else{
pre = p[i].first - delta;
}
}
return pre >= L;
}
int main() {
cin >> n >> L;
for (int i = 1; i <= n; i++){
cin >> p[i].first >> p[i].second;
}
double l = 0, r = 1e9 + 1;
while (r - l > 1e-3){
double mid = (r + l) / 2;
if (check(mid)){
r = mid;
}
else{
l = mid;
}
}
cout << fixed << setprecision(4) << r << "\n";
return 0;
}