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;
using ld = long double;
using ld2 = array<ld, 2>;
const ld diff = 1e-3;
int n;
ld h;
vector<ld2> pts;
ld2 range(ld dist, ld2& pt) {
ld dx = sqrt(dist*dist - pt[1]*pt[1]);
return {pt[0] - dx, pt[0] + dx};
}
bool check(ld dist) {
ld left = 0;
for (ld2& pt: pts) {
ld2 r = range(dist, pt);
if (r[0] <= left) left = max(left, r[1]);
}
return (left >= h);
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> h;
pts.resize(n);
for (auto& i: pts) cin >> i[0] >> i[1];
// solve
ld l = 0, r = 1.5e9, m;
while (r - l > diff) {
m = (r + l) / 2;
if (check(m)) r = m;
else l = m;
}
printf("%.3Lf\n", m);
}
# | 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... |