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 <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
cin.tie(0); iostream::sync_with_stdio(false);
int n;
double d;
cin >> n >> d;
vector<double> x, y;
x.reserve(n); y.reserve(n);
while (n--) {
double xx, yy; cin >> xx >> yy;
yy = fabs(yy);
if (!x.empty() && x.back() == xx) {
y.back() = min(y.back(), yy);
} else {
x.push_back(xx);
y.push_back(yy);
}
}
n = x.size();
double L = 0, R = 4e9;
while (R - L > 1e-3) {
double M = (L + R) / 2;
vector<pair<double, double>> segs;
for (int i = 0; i < n; ++i) if (M > y[i]) {
double len = sqrt(M*M - y[i]*y[i]);
double start = max((double)0.0, x[i] - len), end = min(d, x[i] + len);
if (start > end) {
continue;
}
while (!segs.empty() && start < segs.back().second) {
start = min(start, segs.back().first);
end = max(end, segs.back().second);
segs.pop_back();
}
segs.push_back({start, end});
}
if (segs.empty() || segs.size() > 1 || segs.back().first > 0 || segs.back().second < d) {
L = M;
} else {
R = M;
}
}
cout.precision(20);
cout << (L+R)/2 << endl;
}
# | 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... |