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>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
#define MOD 1000000007
#define INF 10000000
int n, l;
vector<pii> coords;
bool possible(ld curr) {
ld right_bound = 0;
for (int i = 0; i < n; i++) {
if ((ld) coords[i].second * coords[i].second > curr * curr) continue;
ld left_most = coords[i].first - sqrt(curr * curr - (ld) coords[i].second * coords[i].second);
if (left_most <= right_bound) right_bound = max(right_bound, coords[i].first + sqrt(curr * curr - (ld) coords[i].second * coords[i].second));
}
return right_bound <= l;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
// freopen("multimoo.in", "r", stdin);
// freopen("multimoo.out", "w", stdout);
cin >> n >> l;
coords.resize(n);
for (int i = 0; i < n; i++) {
int x, y;
cin >> x >> y;
coords[i] = {x, y};
}
ld l = 0, r = 1000000000;
for (int iteration = 0; iteration <= 50; iteration++) {
ld mp = (l + r) / 2;
if (possible(mp)) {
l = mp;
} else r = mp;
}
cout.precision(6);
cout << fixed << 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... |