Submission #1011173

#TimeUsernameProblemLanguageResultExecution timeMemory
1011173vjudge1Mobile (BOI12_mobile)C++17
0 / 100
312 ms16636 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); if (pt.size() && pt.back().x == x) { if (pt.back().y <= y) { continue; } else { pt.pop_back(); } } pt.push_back({x, y}); } 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 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...