# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
920891 | Kams7 | Mobile (BOI12_mobile) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
double dist(double k, ll y){
if (k<y) return -1;
return sqrt(k*k - y*y);
}
bool check(ll n, double k, ll l, vector<pair<ll,ll>> v){
double mn = 0;
for (ll i=0; i<n; i++){
ll x = v[i].first, y = v[i].second;
double d = dist(k, y);
if (d==-1) continue;
if (x-d<=mn) mn = max(mn, x+d);
}
return mn>=l;
}
void solve(){
ll n, len; cin >> n >> len;
map<ll, ll> ys;
for (ll i=0; i<n; i++){
ll x, y; cin >> x >> y;
if (ys.find(x) == ys.end()) ys[x] = abs(y);
else ys[x] = min(ys[x], abs(y));
}
vector<pair<ll, ll>> v;
for (auto el: ys){
v.push_back(make_pair(el.first, el.second));
}
sort(v.begin(), v.end());
n = size(v);
double l=0, r=1.5e9;
while (r-l>1e-4){
double mid = ((l+r)/2);
if (check(n, mid, len, v)) r=mid;
else l=mid;
}
cout << l << "\n";
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(NULL);
// your code goes here
// int t;
// cin >> t;
// while (t--)
solve();
}