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 <iostream>
#include <vector>
#include <math.h>
#define mp make_pair
using namespace std;
int N;
double L;
vector<pair<double,double> > points;
vector<pair<double,double> > segs;
bool test(double r) {
for(int i=0;i<N;i++) {
double x = points[i].first, y=points[i].second;
double d = sqrt(r*r-y*y);
segs[i].first=x-d;
segs[i].second=x+d;
}
double left=0;
for(int i=0;i<N;i++) {
if(segs[i].first<=left) {
left=max(left,segs[i].second);
}
}
return left>=L;
}
int main() {
cin>>N>>L;
segs.resize(N);
points.resize(N);
for(int i=0;i<N;i++) {
cin>>points[i].first>>points[i].second;
}
double a = 1, b=1e9;
double res=1e9;
while(abs(a-b)>=1e-5) {
double k=(a+b)/2;
if(test(k)) {
res=min(res,k);
b=k;
} else {
a=k;
}
}
cout<<res;
}
# | 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... |