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 <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#define ll long long
#define DBL_MAX 1.79769e+308
#define DBL_MIN -1.79769e+308
using namespace std;
ll N, L;
pair<double, double> arr[1000000];
bool check (double val) {
// cout << endl;
// cout << "val: " << val << endl;
double left = DBL_MAX;
double right = DBL_MIN;
for (int i = 0; i < N; i++) {
double res = sqrt(val * val - arr[i].second * arr[i].second);
// cout << fixed << setprecision(3) << "arr[i].first: " << arr[i].first << " arr[i].second: " << arr[i].second << endl;
// cout << fixed << setprecision(3) << "res: " << res << endl;
if (arr[i].first - res <= left) {
left = arr[i].first - res;
left = max(left, 0.0);
} else if (arr[i].first - res > right) {
return true;
}
if (arr[i].first + res >= right) {
right = arr[i].first + res;
right = min(right, (double)L);
}
//cout << fixed << setprecision(3) << "left: " << left << " right: " << right << endl;
}
if (left == 0.0 && right == L) {
return false;
} else {
return true;
}
}
int main() {
cin >> N >> L;
for (int i = 0; i < N; i++) {
double x, y;
cin >> x >> y;
arr[i] = {x, y};
}
sort(arr, arr + N, [](pair<double, double> a, pair<double, double> b) {
return abs(a.second) < abs(b.second);
});
// cout << "arr: " << endl;
// for (int i = 0; i < N; i++) {
// cout << fixed << setprecision(3) << arr[i].first << " " << arr[i].second << endl;
// }
double ans = 0;
for (double diff = 1e9; diff > 1e-5; diff /= 2) {
if (check(ans + diff)) {
ans += diff;
}
}
cout << fixed << setprecision(5) << ans << endl;
}
# | 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... |