Submission #1011165

#TimeUsernameProblemLanguageResultExecution timeMemory
1011165vjudge1Mobile (BOI12_mobile)C++17
0 / 100
260 ms25352 KiB
#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); while (pt.size() && pt.back().x == x) { if (pt.back().y >= y) { pt.pop_back(); } else { break; } } if (pt.size() && pt.back().x == x) { continue; } pt.push_back({x, y}); } double ans = 1E18; Point lt{0, 0}, rt{l, 0}; for (int i = 0; i < (int)pt.size(); i++) { auto cur = pt[i]; ans = std::min(ans, std::max(dist(cur, lt), dist(cur, rt))); if (i > 0) { auto pre = pt[i - 1]; double x0 = insec(pre, cur); if (x0 > 0 && x0 < l) { Point mid{x0, 0}; ans = std::min(ans, std::max(dist(pre, mid), dist(mid, cur))); } } if (i + 1 < (int)pt.size()) { auto nxt = pt[i + 1]; double x0 = insec(cur, nxt); if (x0 > 0 && x0 < l) { Point mid{x0, 0}; ans = std::min(ans, std::max(dist(cur, mid), dist(mid, nxt))); } } } std::cout << std::fixed << std::setprecision(6) << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...