이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
// Function to check if all points on the highway [0, L] can be covered with distance R
bool canCoverAllPoints(const vector<pair<double, double>>& stations, double R, double L) {
double coverageEnd = 0.0;
for (const auto& station : stations) {
double xi = station.first;
double yi = station.second;
if (yi > R) continue; // This base station cannot cover the highway at distance R
double reach = sqrt(R * R - yi * yi);
double startCoverage = xi - reach;
double endCoverage = xi + reach;
// Extend the current coverage
if (startCoverage <= coverageEnd) {
coverageEnd = max(coverageEnd, endCoverage);
}
if (coverageEnd >= L) return true;
}
return coverageEnd >= L;
}
int main() {
int N;
double L;
cin >> N >> L;
vector<pair<double, double>> stations(N);
for (int i = 0; i < N; ++i) {
double xi, yi;
cin >> xi >> yi;
stations[i] = {xi, yi};
}
// Binary search for the smallest possible R
double low = 0.0;
double high = 1e9;
double epsilon = 1e-6; // Precision for the binary search
while (high - low > epsilon) {
double mid = (low + high) / 2.0;
if (canCoverAllPoints(stations, mid, L)) {
high = mid; // Try smaller radius
} else {
low = mid; // Increase radius
}
}
cout << fixed << setprecision(6) << high << endl;
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... |