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 pii pair<int,int>
vector<pii> coords;
double eps = 1e-4;
int N, L;
bool works(double val)
{
double begin = 0;
double end = L;
for(int i = 0; i < N; i++)
{
if(val*val - coords[i].second*coords[i].second < 0)
return false;
double temp_begin = max((double)0,coords[i].first - pow(val*val - coords[i].second*coords[i].second,0.5));
double temp_end = min((double)L,coords[i].first + pow(val*val - coords[i].second*coords[i].second,0.5));
begin = max(temp_begin,begin);
end = min(end,temp_end);
if(begin>end)
return false;
}
return true;
}
int main()
{
cin >> N >> L;
coords.resize(N);
for(int i = 0; i < N; i++)
{
cin >> coords[i].first >> coords[i].second;
}
double lo = 0;
double hi = 1e10;
double mid;
while(abs(hi-lo) > eps)
{
mid = (lo + hi)/2;
if(works(mid))
hi = mid;
else
lo = mid;
}
cout << setprecision(5) << lo << "\n";
}
# | 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... |