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;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, L;
cin >> n >> L;
vector<pair<int, int>> p(n);
for (int i = 0; i < n; i++) {
cin >> p[i].first >> p[i].second;
}
long double l = -1, r = 7;
for (int itr = 0; itr < 14; itr++) {
long double mid = (l + r) / 2.0;
vector<pair<long double, long double>> v;
int ok = 1;
for (int i = 0; i < n; i++) {
long double b = -2.0 * p[i].first;
long double c = (p[i].first * p[i].first) + (p[i].second * p[i].second) - (mid * mid);
long double delta = (b * b) - 4.0 * c;
if (delta < 0) {
continue;
}
long double lb = (-b - sqrtl(delta)) / 2.0, rb = (-b + sqrtl(delta)) / 2.0;
if (lb > (long double) L) {
continue;
}
while (!v.empty() && lb < v.back().first) {
v.pop_back();
}
if (!v.empty() && v.back().second < lb) {
ok = 0;
break;
}
v.push_back({lb, rb});
}
if (v.empty() || !ok || (!v.empty() && ((min((long double) L, end(v)[-1].second) - max(v[0].first, (long double) 0.0)) < (long double) L))) {
l = mid;
} else {
r = mid;
}
}
cout << setprecision(4) << fixed << (r + l) / 2.0 << '\n';
return 0;
}
# | 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... |