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 pr pair<int, int>
#define ll long long
#define pb push_back
#define f first
#define s second
vector<pr> d(1000001);
int n; double L;
bool comp(pr a, pr b){
if(a.f==b.f) return a.s*a.s<b.s*b.s;
return a.f<b.f;
}
int main(){
cin>>n>>L;
for (int i=0; i<n; i++) {
cin>>d[i].f>>d[i].s;
}
//sort(d.begin(), d.begin()+n, comp);
//for (int i=0; i<n; i++) cout<<d[i].f<<" " <<d[i].s<<" :"<<endl;
double lft=0; double rht=L;
while (rht-lft>1e-5){
double mid=lft+(rht-lft)/2;
//cout<<" lft/rht/mid= "<<lft<<" "<<rht<<" "<<mid<<endl;
double curr=0;
for (int i=0; i<n; i++){
double dx=sqrt(mid*mid-d[i].s*d[i].s);
double x1, x2;
x1=d[i].f-dx; x2=d[i].f+dx;
if(x1<=curr) curr=max(curr, x2);
}
if(curr>=L) rht=mid;
else lft=mid;
}
cout << fixed <<setprecision(4);
cout<<lft<<endl;
}
# | 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... |