Submission #1132524

#TimeUsernameProblemLanguageResultExecution timeMemory
1132524vedeshrayMobile (BOI12_mobile)C++20
100 / 100
274 ms15944 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    ll n, l; cin >> n >> l;
    vector<pair<ll, ll>> stations(n);
    for (auto &[x, y] : stations) {cin >> x >> y;}
    double minRad = 0, maxRad = 2e9; // maxRad has to be enough to reach the ends of the highway
    while (minRad < maxRad - 1e-3) { // we have a 1e-3 (.001) leeway on the answer
        double midRad = (minRad + maxRad) / 2;
        double currPoint = 0; // current uncovered point on the highway
        for (auto [x, y] : stations) {
            double b = sqrt(midRad * midRad - y * y); // b = dist from the x coord of the station to the bound of the station's circle intersection on the highway.
            double segLeft = x - b, segRight = x + b;
            if (segLeft <= currPoint) {currPoint = max(currPoint, segRight);}
        }
        if (currPoint >= l) {maxRad = midRad;} // if all the highway has been covered
        else {minRad = midRad;} // means a point was far away enough to not be covered
    }
    cout << fixed << setprecision(6) << minRad << '\n';
}
#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...