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-5;
int N, L;
bool not_works(double val)
{
double curr = 0;
for(int i = 0; i < N; i++)
{
double temp_begin = coords[i].first - sqrt(val*val - coords[i].second*coords[i].second);
double temp_end = coords[i].first + sqrt(val*val - coords[i].second*coords[i].second);
if(temp_begin <= curr)
curr = max(curr, temp_end);
}
if(curr >= L)
return true;
else
return false;
}
int main()
{
cin >> N >> L;
coords.resize(N);
for(int i = 0; i < N; i++)
{
cin >> coords[i].first >> coords[i].second;
}
double lo = 1;
double hi = 1.5e9;
double mid;
while(abs(hi-lo) > eps)
{
mid = (lo + hi)/2;
if(not_works(mid))
hi = mid;
else
lo = mid;
}
cout << setprecision(6) << 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... |