#include <bits/stdc++.h>
#define diff 0.0000001
#define p pair<double,double>
using namespace std;
bool Check(double d,vector<p> v,int n,int l) {
double st,dr;
double distance=sqrt(d*d-v[0].second*v[0].second);
st=max((double)0,v[0].first-distance);
dr=min((double)l,v[0].first+distance);
for (int i=1; i<n; i++) {
double x=v[i].first,y=v[i].second;
double distance=sqrt(d*d-y*y);
if (dr>=max((double)0,x-distance)) dr=min((double)l,x+distance);
else return 0;
}
return (abs((double)l-dr)<=diff && st<=diff);
}
int main()
{
int n,l;
cin>>n>>l;
vector< p > v(n);
for (int i=0; i<n; i++)
cin>>v[i].first>>v[i].second;
double st=0,dr=1e9,mij;
while (abs(dr-st)>diff) {
mij=(st+dr)/2;
//cout<<st<<' '<<dr<<' '<<mij<<'\n';
if (Check(mij,v,n,l)) dr=mij;
else st=mij;
}
cout<<fixed<<setprecision(6)<<dr<<'\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
56 ms |
3260 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
57 ms |
3468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
3824 KB |
Output is correct |
2 |
Incorrect |
73 ms |
3756 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
90 ms |
4688 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
83 ms |
4688 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
370 ms |
18604 KB |
Output is correct |
2 |
Correct |
461 ms |
20148 KB |
Output is correct |
3 |
Correct |
449 ms |
19916 KB |
Output is correct |
4 |
Incorrect |
470 ms |
21156 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
465 ms |
20660 KB |
Output is correct |
2 |
Incorrect |
398 ms |
19636 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
451 ms |
22380 KB |
Output is correct |
2 |
Incorrect |
603 ms |
23992 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
559 ms |
24496 KB |
Output is correct |
2 |
Incorrect |
482 ms |
23204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
536 ms |
25528 KB |
Output is correct |
2 |
Incorrect |
654 ms |
27828 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
670 ms |
28352 KB |
Output is correct |
2 |
Incorrect |
602 ms |
27288 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
632 ms |
29116 KB |
Output is correct |
2 |
Incorrect |
751 ms |
31672 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
771 ms |
32388 KB |
Output is correct |
2 |
Incorrect |
659 ms |
30900 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
754 ms |
36560 KB |
Output is correct |
2 |
Incorrect |
919 ms |
39620 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
939 ms |
40276 KB |
Output is correct |
2 |
Incorrect |
809 ms |
38608 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |