제출 #1093051

#제출 시각아이디문제언어결과실행 시간메모리
1093051TommasoUlianMobile (BOI12_mobile)C++14
0 / 100
766 ms49128 KiB
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#ifndef ONLINE_JUDGE
#define DEBUG(x) cout << #x << " = " << (x) << endl
#else
#define DEBUG(x)
#endif
#define FOR(n) for(int i = 0; i < (n); i++)
#define SORTA(v) sort((v).begin(), (v).end())
#define SORTD(v) sort((v).rbegin(), (v).rend())
#define PRINT(v) for(auto x: (v))cout << x << " "; cout << endl;
#define TWO(n) (1 << (n))
#define INPUT(v) for(auto &x : (v))cin >> x;

typedef long long ll;

using namespace std;

vector<pair<double, double>> torri;
ll n, L;

bool good(double r) {
    queue<pair<double, double>> s;
    
    for (auto a : torri) {
        double x = a.first, y = a.second;
        if (abs(y) <= r - 1e-6) {
            // Calculate the horizontal range covered by the tower at radius r
            double dx = sqrt((r + y) * (r - y));
            s.push({x - dx, x + dx});
        }
    }
    
    double curr = 0;
    while (!s.empty()) {
        if (curr >= L) return true;
        auto seg = s.front();
        s.pop();
        if (seg.first <= curr) {
            curr = max(seg.second, curr);
        } else {
            return false;
        }
    }
    
    return curr >= L;
}

void solve() {
    cin >> n >> L;
    torri = vector<pair<double, double>>(n);
    for (int i = 0; i < n; i++) {
        cin >> torri[i].first >> torri[i].second;
    }

    double l = 0, r = 2e9;  // Adjust upper bound based on problem limits
    double ans = r;

    while (r - l >= 1e-6) {  // Adjust precision here for better accuracy
        double c = (r + l) / 2;
        if (good(c)) {
            ans = c;
            r = c;
        } else {
            l = c;
        }
    }

    cout << ans << endl;
}

int main() {
    cout << setprecision(18);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    solve();
    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...