Submission #1083687

#TimeUsernameProblemLanguageResultExecution timeMemory
1083687vjudge1Mobile (BOI12_mobile)C++17
95 / 100
1004 ms35420 KiB
#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 currentCoverage = 0.0; for (const auto& station : stations) { double xi = station.first; double yi = station.second; if (yi > R) continue; // This base station cannot help at this R double reach = sqrt(R * R - yi * yi); double startCoverage = max(0.0, xi - reach); double endCoverage = xi + reach; // Extend coverage if this base station helps if (startCoverage <= currentCoverage) { currentCoverage = max(currentCoverage, endCoverage); } if (currentCoverage >= L) return true; } return currentCoverage >= 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-4; // Precision to ensure accuracy within 1e-3 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 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...