#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define endl '\n'
#define int ll
#define ld long double
#define pdd pair<ld, ld>
using namespace std;
int dist2(pii a, pii b)
{
return (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second);
}
ld dist(pii a, ld x)
{
return sqrt((((ld)a.first) - x) * (((ld)a.first) - x) + (ld)(a.second * a.second));
}
const int INF2 = 1e12;
const int INF = 1e9 + 1;
ld eps = 1e-4;
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int N, L;
cin >> N >> L;
vector<pii> inp(N);
map<int, int> closest;
for (int i = 0; i < N; i++)
{
int x, y;
cin >> x >> y;
inp[i] = {x, y};
if (!closest.count(x))
closest[x] = y;
else
closest[x] = (abs(closest[x]) > abs(y) ? y : closest[x]);
}
vector<pii> pts;
for (pii p : closest)
pts.push_back(p);
N = pts.size();
auto calc_bp = [&](int idx1, int idx2)
{
ld x1 = pts[idx1].first, y1 = pts[idx1].second;
ld x2 = pts[idx2].first, y2 = pts[idx2].second;
return ((ld)0.5) * (x1 + x2 + (y1 * y1 - y2 * y2) / (x1 - x2));
};
stack<int> stk;
stk.push(0);
vector<ld> dists, bps;
for (int i = 1; i < N; i++)
{
ld bp = calc_bp(stk.top(), i);
while (!bps.empty() && bps.back() > bp)
{
bps.pop_back();
stk.pop();
dists.pop_back();
bp = calc_bp(stk.top(), i);
}
bps.push_back(bp);
dists.push_back(dist(pts[i], bp));
stk.push(i);
}
ld mx_dist = 0;
for (int i = 0; i < (bps.empty() ? 0 : bps.size()); i++)
{
if (bps[i] < 0 || bps[i] > L)
continue;
mx_dist = max(mx_dist, dists[i]);
}
ld mn_start = INF2, mn_end = INF2;
for (int i = 0; i < N; i++)
{
mn_start = min(mn_start, dist(pts[i], 0));
mn_end = min(mn_end, dist(pts[i], L));
}
mx_dist = max({mx_dist, mn_start, mn_end});
cout << setprecision(4) << fixed << mx_dist << endl;
}
Compilation message
mobile.cpp: In function 'int main()':
mobile.cpp:83:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'long unsigned int' [-Wsign-compare]
83 | for (int i = 0; i < (bps.empty() ? 0 : bps.size()); i++)
| ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
764 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
600 KB |
Output is correct |
2 |
Correct |
2 ms |
856 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
604 KB |
Output is correct |
2 |
Correct |
2 ms |
856 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
860 KB |
Output is correct |
2 |
Correct |
2 ms |
860 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
904 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
7888 KB |
Output is correct |
2 |
Correct |
31 ms |
6320 KB |
Output is correct |
3 |
Correct |
20 ms |
5588 KB |
Output is correct |
4 |
Correct |
37 ms |
8400 KB |
Output is correct |
5 |
Correct |
6 ms |
1116 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
2140 KB |
Output is correct |
2 |
Correct |
29 ms |
4792 KB |
Output is correct |
3 |
Correct |
33 ms |
8096 KB |
Output is correct |
4 |
Correct |
36 ms |
8652 KB |
Output is correct |
5 |
Correct |
38 ms |
9432 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
35 ms |
14176 KB |
Output is correct |
2 |
Correct |
33 ms |
6104 KB |
Output is correct |
3 |
Correct |
36 ms |
12748 KB |
Output is correct |
4 |
Correct |
48 ms |
10200 KB |
Output is correct |
5 |
Correct |
28 ms |
3548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
40 ms |
5832 KB |
Output is correct |
2 |
Correct |
40 ms |
5836 KB |
Output is correct |
3 |
Correct |
34 ms |
3664 KB |
Output is correct |
4 |
Correct |
49 ms |
10440 KB |
Output is correct |
5 |
Correct |
43 ms |
9156 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
50 ms |
12484 KB |
Output is correct |
2 |
Correct |
40 ms |
5836 KB |
Output is correct |
3 |
Correct |
33 ms |
3920 KB |
Output is correct |
4 |
Correct |
48 ms |
10444 KB |
Output is correct |
5 |
Correct |
43 ms |
9156 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
236 ms |
70336 KB |
Output is correct |
2 |
Correct |
155 ms |
8988 KB |
Output is correct |
3 |
Correct |
149 ms |
9040 KB |
Output is correct |
4 |
Correct |
273 ms |
48572 KB |
Output is correct |
5 |
Correct |
240 ms |
37384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
150 ms |
9020 KB |
Output is correct |
2 |
Correct |
247 ms |
49752 KB |
Output is correct |
3 |
Correct |
215 ms |
21448 KB |
Output is correct |
4 |
Correct |
261 ms |
48756 KB |
Output is correct |
5 |
Correct |
262 ms |
45780 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
296 ms |
99052 KB |
Output is correct |
2 |
Correct |
186 ms |
10328 KB |
Output is correct |
3 |
Correct |
170 ms |
10320 KB |
Output is correct |
4 |
Correct |
312 ms |
63940 KB |
Output is correct |
5 |
Correct |
301 ms |
37056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
181 ms |
10320 KB |
Output is correct |
2 |
Correct |
314 ms |
63460 KB |
Output is correct |
3 |
Correct |
252 ms |
19912 KB |
Output is correct |
4 |
Correct |
334 ms |
63940 KB |
Output is correct |
5 |
Correct |
312 ms |
59456 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
350 ms |
111512 KB |
Output is correct |
2 |
Correct |
189 ms |
11860 KB |
Output is correct |
3 |
Correct |
191 ms |
11824 KB |
Output is correct |
4 |
Correct |
381 ms |
71720 KB |
Output is correct |
5 |
Correct |
325 ms |
36292 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
205 ms |
11992 KB |
Output is correct |
2 |
Correct |
353 ms |
71100 KB |
Output is correct |
3 |
Correct |
319 ms |
28108 KB |
Output is correct |
4 |
Correct |
395 ms |
71612 KB |
Output is correct |
5 |
Correct |
358 ms |
65216 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
409 ms |
124060 KB |
Output is correct |
2 |
Correct |
211 ms |
13296 KB |
Output is correct |
3 |
Correct |
212 ms |
13396 KB |
Output is correct |
4 |
Correct |
433 ms |
79548 KB |
Output is correct |
5 |
Correct |
398 ms |
60548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
227 ms |
26200 KB |
Output is correct |
2 |
Correct |
405 ms |
89272 KB |
Output is correct |
3 |
Correct |
376 ms |
38472 KB |
Output is correct |
4 |
Correct |
461 ms |
94552 KB |
Output is correct |
5 |
Correct |
426 ms |
82824 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
468 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
274 ms |
32336 KB |
Output is correct |
2 |
Correct |
533 ms |
110500 KB |
Output is correct |
3 |
Correct |
485 ms |
51112 KB |
Output is correct |
4 |
Correct |
564 ms |
113852 KB |
Output is correct |
5 |
Correct |
540 ms |
99264 KB |
Output is correct |