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>
using namespace std;
const int N = 1e5 + 5;
int n;
double m;
double x[N], y[N];
pair<double, double> calc(double r, int i) {
if (r < abs(y[i])) {
return {-1, -1};
}
return {x[i] - sqrt(r * r - y[i] * y[i]), x[i] + sqrtl(r * r - y[i] * y[i])};
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
double l = 2e9, r = 1.5e9;
for (int i = 1; i <= n; ++i) {
cin >> x[i] >> y[i];
l = min(l, abs(y[i]));
}
while (r - l >= 1e-3) {
vector<pair<double, double>> segments;
double mid = (l + r) / 2;
for (int i = 1; i <= n; ++i) {
auto x = calc(mid, i);
if (x.first != -1 || x.second != -1) {
segments.emplace_back(x.first, x.second);
}
}
sort(segments.begin(), segments.end());
double bound = 0;
for (auto x : segments) {
if (x.first > bound) {
break;
}
bound = max(bound, x.second);
if (bound >= m) {
break;
}
}
if (bound >= m) {
r = mid;
} else {
l = mid;
}
}
cout << fixed << setprecision(6) << l << '\n';
}
# | 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... |