#include "bits/stdc++.h"
#define INF 1e18
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
double n, l;
cin >> n >> l;
vector<pair<double, double>> stations(n);
for (int i = 0; i < n; i++) {
cin >> stations[i].first >> stations[i].second;
}
stack<pair<double, double>> s;
s.push({0, 0});
for (int i = 1; i < n; i++) {
double d = (pow(stations[i].first, 2) + pow(stations[i].second, 2) - pow(stations[s.top().first].first, 2)
- pow(stations[s.top().first].second, 2)) / (2 * (stations[i].first - stations[s.top().first].first));
while (!s.empty() && d < s.top().first) {
s.pop();
d = (pow(stations[i].first, 2) + pow(stations[i].second, 2) - pow(stations[s.top().first].first, 2)
- pow(stations[s.top().first].second, 2)) / (2 * (stations[i].first - stations[s.top().first].first));
}
s.push({i, d});
}
double r = pow(stations[s.top().first].first - l, 2) + pow(stations[s.top().first].second, 2);
while (!s.empty()) {
pair<double, double> p = s.top();
s.pop();
r = max(r, pow(stations[p.first].first - p.second, 2) + pow(stations[p.first].second, 2));
}
cout << sqrt(r) << 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... |