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;
vector<pair<int,int>> pts;
int n;
double L;
bool works(double d){
// whether a radius of d is enough to intersect all the circles
double currDistCovered = 0.0;
for(int i = 0; i < n; i++){
// find the segment covered by ith circle on the highway
// radius^2 = yi^2 + dist^2
double dist = sqrt(d*d - pts[i].second*pts[i].second);
double start = pts[i].first - dist;
double end = pts[i].first + dist;
if(start <= currDistCovered){
currDistCovered = max(currDistCovered, end);
}
}
return currDistCovered >= L;
}
int main() {
cin >> n >> L;
pts.resize(n);
for(int i = 0; i < n; i++) cin >> pts[i].first >> pts[i].second;
double good = 5e9;
double bad = -1.0;
for(int i = 0; i < 60; i++){
double mid = bad + (good - bad)/2;
if(works(mid)){
good = mid;
} else {
bad = mid;
}
}
cout << fixed << setprecision(6) << good;
}
# | 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... |