This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Source: https://usaco.guide/general/io
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
#define mp make_pair
constexpr int MAX_C = 1.5e9;
constexpr int MAX_N = 1e6;
using pi = pair<int, int>;
using pd = pair<double, double>;
int n, l;
pi towers[MAX_N];
bool check(double p) {
// cout << "Called: " << p << endl;
double best = 0;
for(int i = 0; i < n; ++i) {
if(abs(towers[i].s) >= p) continue;
double dist = sqrt(p * p - towers[i].s * towers[i].s);
double d1 = towers[i].f - dist, d2 = towers[i].f + dist;
if(d1 <= best) best = max(best, d2);
}
if(best > l) return true;
return false;
}
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> l;
for(int i = 0; i < n; ++i) cin >> towers[i].f >> towers[i].s;
double le = 1e-4, r = MAX_C;
while(r - le >= 1e-3) {
double mid = (le + r) / 2;
if(check(mid)) r = mid;
else le = mid;
}
cout.precision(4);
cout << fixed << le << '\n';
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... |