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 <vector>
#include <cmath>
using namespace std;
int main() {
int N, L;
cin >> N >> L;
vector<pair<int, int>> tr(N);
for (auto& p : tr) cin >> p.first >> p.second;
double low = 0, high = 3 * 1e9;
while (low + 1e-5 < high) {
double r = (high + low) / 2;
vector<pair<double, double>> s;
for (auto& p : tr) {
if (abs(p.second) >= r) continue;
double x = sqrt(r* r - p.second * p.second);
double x1 = p.first - x, x2 = p.first + x;
// x2 >= s.back().first is always true. That's why we can use merge with stack.
while (!s.empty() && s.back().second >= x1) {
x1 = min(x1, s.back().first);
x2 = max(x2, s.back().second);
s.pop_back();
}
s.push_back({x1, x2});
}
bool ok = false;
for (auto& p : s) {
if (p.first <= 0 && p.second >= L) {
ok = true;
}
}
if (ok) {
high = r;
} else {
low = r;
}
}
cout << high << endl;
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... |