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 i64 = long long;
struct Point {
double x, y;
};
double dist(const Point &a, const Point &b) {
double dx = a.x - b.x;
double dy = a.y - b.y;
return std::sqrt(dx * dx + dy * dy);
}
double insec(const Point &a, const Point &b) {
double t1 = b.x * b.x + b.y * b.y - a.x * a.x - a.y * a.y;
double t2 = b.x - a.x;
return t1 / t2 / 2;
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
double l;
std::cin >> n >> l;
std::deque<Point> pt;
for (int i = 0; i < n; i++) {
double x, y;
std::cin >> x >> y;
y = std::abs(y);
if (pt.size() && pt.back().x == x) {
if (pt.back().y <= y) {
continue;
} else {
pt.pop_back();
}
}
Point cur{x, y};
while ((int)pt.size() > 1 && insec(pt[pt.size() - 1], pt[pt.size() - 2]) > insec(pt[pt.size() - 1], cur)) {
pt.pop_back();
}
pt.emplace_back(cur);
}
while ((int)pt.size() > 1 && insec(pt[0], pt[1]) < 0) {
pt.pop_front();
}
while ((int)pt.size() > 1 && insec(pt[pt.size() - 1], pt[pt.size() - 2]) > l) {
pt.pop_back();
}
double ans = 0;
Point lt{0, 0}, rt{l, 0};
for (int i = 0; i < (int)pt.size(); i++) {
if (i > 0) {
lt.x = insec(pt[i], pt[i - 1]);
}
if (i + 1 < (int)pt.size()) {
rt.x = insec(pt[i], pt[i + 1]);
}
if (lt.x < 0 || lt.x > l || rt.x < 0 || rt.x > l) {
continue;
}
ans = std::max({ans, dist(lt, pt[i]), dist(pt[i], rt)});
}
std::cout << std::fixed << std::setprecision(6) << ans << "\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... |