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, d; cin >> n >> d;
vector<double> x, y;
x.reserve(n); y.reserve(n);
double R = 2e9, L1 = R, L2 = R;
while (n--) {
int xx, yy; cin >> xx >> yy;
yy = abs(yy);
if (!x.empty() && x.back() == xx) {
y.back() = min(y.back(), (double)yy);
} else {
x.push_back(xx);
y.push_back(yy);
}
auto d1 = hypot(xx, (double)yy);
auto d2 = hypot(d-xx, (double)yy);
R = min(R, max(d1, d2));
L1 = min(L1, d1);
L2 = min(L1, d2);
}
double L = max(L1, L2);
n = x.size();
while (R > L + 1e-3) {
double M = L + (R-L)/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(0.0, x[i] - len), end = min((double)d, x[i] + len);
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 << (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... |