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 lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44
using namespace std;
const double eps = 1e-9;
const double INF = 1e18;
const int MAXN = (int) 1e6;
struct Point {
double x, y;
}pts[MAXN + 1];
inline double dist(Point a, Point b) {
return sqrt(1LL * (a.x - b.x) * (a.x - b.x) + 1LL * (a.y - b.y) * (a.y - b.y));
}
struct Data {
double l, r;
int id;
};
vector <Data> stk;
inline bool eq(double a, double b) {
return fabs(a - b) < eps;
}
double L;
inline bool ok(double &l, double &r, Point b) {
Point a = pts[stk.back().id];
if(eq(a.x, b.x)) {
return 0;
}
double x = 1.0 * (b.x * b.x + b.y * b.y - a.x * a.x - a.y * a.y) / (2 * (b.x - a.x));
if(x > L) {
return 0;
}
x = max(x, (double) 0.0);
if(x - stk.back().l > 0) {
stk.back().r = x;
l = x;
r = L;
return 0;
}
l = stk.back().l;
r = L;
return 1;
}
int main() {
//ifstream cin("B.in");
//ofstream cout("B.out");
int i, n;
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n >> L;
int sz = 0;
for(i = 1; i <= n; i++) {
double x, y;
cin >> x >> y;
y = fabs(y);
if(sz > 0 && eq(x, pts[sz].x)) {
pts[sz].y = min(pts[sz].y, y);
}
else {
pts[++sz] = {x, y};
}
}
n = sz;
stk.push_back({0, L, 1});
for(i = 2; i <= n; i++) {
double l = INF, r = -INF;
while(!stk.empty()) {
if(ok(l, r, pts[i])) {
stk.pop_back();
}
else {
break;
}
}
if(r - l > 0) {
stk.push_back({l, r, i});
}
}
double ans = 0;
for(auto it : stk) {
ans = max(ans, dist(pts[it.id], {it.l, 0}));
ans = max(ans, dist(pts[it.id], {it.r, 0}));
}
cout << fixed << setprecision(20) << ans;
//cin.close();
//cout.close();
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... |