Submission #1146846

#TimeUsernameProblemLanguageResultExecution timeMemory
1146846hellowinchang1029Mobile (BOI12_mobile)C++20
100 / 100
404 ms16044 KiB
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vvi vector<vector<int>>
#define vt vector
#define arr array
#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
#define SZ(x) x.size()
#define P(x, y) make_pair(x, y)
const int MOD1=998244353;
const int MOD2=1e9+7;
const ll LINF=1e18;
const int INF=1e9;

int N;
double L;
vt<pair<double, double>> points;

bool valid(double d){
    double covered = 0;
    for (auto [x, y] : points){
        // x ^ 2 + y ^ 2 = r ^ 2
        double dist = sqrt(d * d - y * y);
        if (x - dist <= covered) covered = max(covered, x + dist);
        if (covered >= L) return 1;
    }
    return 0;
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    cin >> N >> L;
    points.resize(N);
    for (auto &[x, y] : points) cin >> x >> y;

    double l = 0, r = 1.5e9;
    while(r - l > 1e-3){
        double m = (l + r) / 2;
        if (valid(m)) r = m;
        else l = m;
    }
    cout << fixed << setprecision(10) << l << '\n';
    
    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...