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 <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <iomanip>
using namespace std;
using ld = long double;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
ld L;
cin >> n >> L;
vector<pair<ld, ld>> xy(n);
for (int i = 0; i < n; i++) cin >> xy[i].first >> xy[i].second;
ld l = 0, r = 4e9;
int it = 45;
while (it--)
{
ld m = (l + r) / 2;
stack<pair<ld, ld>> c;
for (int i = 0; i < n; i++) if (xy[i].second <= m)
{
ld sq = sqrt(m * m - xy[i].second * xy[i].second);
ld a = fmax(0, xy[i].first - sq), b = fmin(L, xy[i].first + sq);
while (!c.empty() && ((c.top().second >= a) || (c.top().second <= -a)))
{
a = fmin(a, c.top().first), b = fmax(b, c.top().second);
c.pop();
}
c.push({ a, b });
}
if ((c.size() != 1) || ((c.top().first > 0) || (c.top().second < L))) l = m;
else r = m;
}
cout << fixed << setprecision(3) << l;
}
# | 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... |