This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#define ll long long
#define ull unsigned long long
#define pdd std::pair<double, double>
#define NMAX 1e6
#define LMAX 1e9
#define INF 3e9
struct Tower {
double x, y;
};
struct Seg {
double st, fn;
};
double n, l;
std::vector<Tower> s;
void citire() {
std::cin >> n >> l;
s.resize(n);
for (int i = 0; i < n; i++) {
std::cin >> s[i].x >> s[i].y;
}
}
double b_search(double lo, double hi, std::function<bool(double)> f) {
// std::cout << "a\n";
for (int i = 1; hi - lo > 0.001; i++) {
double mid = (lo + hi) / 2;
if (f(mid))
hi = mid;
else
lo = mid;
}
return lo;
}
bool find_point(double k) {
std::vector<Seg> segs;
for (Tower &it : s) {
if (k * k < it.y * it.y)
continue;
double max_dx = sqrt(k * k - it.y * it.y);
segs.push_back({it.x - max_dx, it.x + max_dx});
}
Seg curr_inter = {-INF, INF};
for (Seg &it : segs) {
if (it.fn < curr_inter.st || it.st > curr_inter.fn)
return 0;
if (it.st > curr_inter.fn)
return 0;
if (it.st >= curr_inter.st) {
curr_inter.st = it.st;
}
if (it.fn <= curr_inter.fn) {
curr_inter.fn = it.fn;
}
}
return 1;
}
int main() {
citire();
// std::cout << "out\n";
double k = b_search(0, INF, find_point);
std::cout << std::setprecision(10) << k;
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... |