// oh, these hills, they burn so bright / oh, these hills, they bring me life
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define all(x) begin(x), end(x)
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)(x.size())
#define inf 1000000010
#define linf 0x3f3f3f3f3f3f3f3f
#define mp make_pair
#define f first
#define s second
#define pi pair<int, int>
#ifdef LOCAL
#include "/mnt/c/yukon/pp.hpp"
#else
#define endl '\n'
#endif
#define double long double
struct Point {
double x, y;
};
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, l;
cin >> n >> l;
function<double(Point, Point)> max_point = [&](Point a, Point b) {
// return (((b.x) * (b.x)) + ((b.y) * (b.y)) - ((a.x) * (a.x)) - ((a.y) * (a.y))) / (2 * (b.x - a.x));
return (b.x * b.x + b.y * b.y - a.x * a.x - a.y * a.y) / (2 * b.x - 2 * a.x);
};
function<double(Point, Point)> dist = [&](Point a, Point b) {
return sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2));
};
deque<Point> stck;
for (int i = 0; i < n; i++) {
Point cur;
cin >> cur.x >> cur.y;
cur.y = abs(cur.y);
// take the one with the lowest y coord
if (sz(stck) && stck.back().x == cur.x) {
if (cur.y >= stck.back().y) {
continue;
} else if (cur.y < stck.back().y) {
stck.pop_back();
}
}
// find "crosses"
while (sz(stck) > 1 && max_point(stck[sz(stck) - 2], stck.back()) > max_point(stck.back(), cur)) {
stck.pop_back();
}
stck.push_back(cur);
}
while (sz(stck) > 1 && max_point(stck[0], stck[1]) < 0)
stck.pop_front();
while (sz(stck) > 1 && max_point(stck[sz(stck) - 2], stck.back()) > l)
stck.pop_back();
double ans = 0;
for (int x = 0; x < sz(stck); x++) {
Point left = {(x ? max_point(stck[x], stck[x - 1]) : 0), 0};
if (stck[x - 1].x < 0 || stck[x - 1].x > l)
left.x = 0;
Point right = {(x < sz(stck) - 1 ? max_point(stck[x], stck[x + 1]) : l), 0};
if (stck[x + 1].x < 0 || stck[x + 1].x > l)
right.x = l;
if (right.x < 0 || left.x > l)
continue;
ans = max({ans, dist(stck[x], left), dist(stck[x], right)});
}
cout << fixed << setprecision(6) << ans << endl;
}
// don't get stuck on one approach
// question bounds
// flesh out your approach before implementing o.o
// math it out
// ok well X is always possible, how about X + 1 (etc.)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Runtime error |
3 ms |
604 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
1364 KB |
Output is correct |
2 |
Correct |
28 ms |
1112 KB |
Output is correct |
3 |
Correct |
20 ms |
1116 KB |
Output is correct |
4 |
Incorrect |
31 ms |
1616 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
25 ms |
860 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
34 ms |
6740 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
1372 KB |
Output is correct |
2 |
Correct |
34 ms |
1616 KB |
Output is correct |
3 |
Correct |
30 ms |
1908 KB |
Output is correct |
4 |
Correct |
58 ms |
2636 KB |
Output is correct |
5 |
Correct |
48 ms |
1596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
40 ms |
3492 KB |
Output is correct |
2 |
Correct |
35 ms |
1364 KB |
Output is correct |
3 |
Correct |
30 ms |
1872 KB |
Output is correct |
4 |
Correct |
56 ms |
2484 KB |
Output is correct |
5 |
Correct |
38 ms |
1588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
188 ms |
36420 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
168 ms |
5512 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
204 ms |
43344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
205 ms |
5864 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
240 ms |
50356 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
240 ms |
6540 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
278 ms |
57932 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
267 ms |
7760 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
374 ms |
71596 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
331 ms |
9268 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |