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 namespace std;
typedef long long ll;
vector<pair<double, double>> torri;
ll n, L;
bool canCover(double r) {
double curr = 0.0; // Current coverage along the highway
for (int i = 0; i < n; i++) {
double x = torri[i].first;
double y = torri[i].second;
// Calculate the horizontal coverage from the station
if (abs(y) > r) continue; // Ignore stations that cannot reach the highway
double dx = sqrt((r * r) - (y * y)); // Width of coverage
double left = x - dx; // Left end of coverage
double right = x + dx; // Right end of coverage
// If the current position is within the coverage
if (left <= curr + 1e-6) {
curr = max(curr, right); // Extend current coverage
}
// Early exit if the entire highway is covered
if (curr >= L) return true;
}
return curr >= L; // Final check if we covered the highway
}
void solve() {
cin >> n >> L;
torri.resize(n);
for (int i = 0; i < n; i++) {
cin >> torri[i].first >> torri[i].second;
}
double l = 1.0, r = 2e9; // Reasonable bounds for binary search
double ans = r;
// Perform binary search
while (r - l > 1e-4) {
double mid = (l + r) / 2;
if (canCover(mid)) {
ans = mid; // Update best answer
r = mid; // Try for a smaller radius
} else {
l = mid; // Increase radius
}
}
cout << setprecision(18) << ans << endl; // Output the result
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
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... |