#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define fi first
#define se second
#define test(v) \
for (auto &x : (v)) { \
cout << x << " "; \
} \
cout << "\n";
#define test2d(v) \
for (int i = 0; i < (int)v.size(); i++) { \
for (int j = 0; j < (int)v[i].size(); j++) { \
cout << v[i][j] << " "; \
} \
cout << '\n'; \
}
#define pb push_back
vector<pair<int, int>> dirs = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
mt19937 rng((int)chrono::steady_clock::now().time_since_epoch().count());
int hashp = uniform_int_distribution<int>(10, 1e9)(rng);
int hashm1 = 1e9+7;
int hashm2 = 1e9+9;
int MOD = 1e9 + 7;
bool check(long double dist, vector<array<int, 2>>& a, int len){
vector<array<long double, 2>> pos;
for(auto[x, y]: a){
if (abs(y) > dist) continue;
long double l = x - sqrt(dist*dist - y*y);
long double r = x + sqrt(dist*dist - y*y);
pos.pb({l, r});
}
if (pos.empty()) return true;
sort(pos.begin(), pos.end(), greater<>());
while(pos.size() > 1){
auto[l, r] = pos.back();
pos.pop_back();
auto[nl, nr] = pos.back();
pos.pop_back();
if(r >= nr){
pos.pb({l, r});
} else{
if(nl > r) return true;
else pos.pb({l, nr});
}
}
return (pos[0][0] > 1e-7 || pos[0][1] < (long double)len - 1e-7);
}
void solve(){
int n, L;
cin >> n >> L;
vector<array<int, 2>> a(n);
for(int i = 0; i < n; i++){
cin >> a[i][0] >> a[i][1];
}
long double l = 0, r = 5e9;
while(r - l > 1e-7){
long double m = l + (r-l)/2;
if(check(m, a, L)) l = m;
else r = m;
}
cout << fixed << setprecision(7) << l;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
/*
freopen("feast.in", "r", stdin);
freopen("feast.out", "w", stdout);
*/
solve();
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |