#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)
{
ld x1 = a.first, y = a.second;
return sqrt((x1 - x) * (x1 - x) + y * y);
}
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;
while (x1 == x2)
{
}
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);
bool emp = false;
while (!bps.empty() && bps.back() > bp)
{
bps.pop_back();
stk.pop();
dists.pop_back();
if (stk.empty())
emp = true;
else
bp = calc_bp(stk.top(), i);
}
if (!emp)
{
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:94:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'long unsigned int' [-Wsign-compare]
94 | for (int i = 0; i < (bps.empty() ? 0 : bps.size()); i++)
| ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 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 |
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 |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
860 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
2 ms |
1116 KB |
Output is correct |
3 |
Correct |
1 ms |
600 KB |
Output is correct |
4 |
Correct |
3 ms |
1116 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
856 KB |
Output is correct |
2 |
Correct |
2 ms |
1116 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
1116 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
860 KB |
Output is correct |
2 |
Correct |
2 ms |
1116 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
984 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
8656 KB |
Output is correct |
2 |
Correct |
33 ms |
7244 KB |
Output is correct |
3 |
Correct |
21 ms |
6356 KB |
Output is correct |
4 |
Correct |
33 ms |
9644 KB |
Output is correct |
5 |
Correct |
6 ms |
1628 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
2904 KB |
Output is correct |
2 |
Correct |
27 ms |
5580 KB |
Output is correct |
3 |
Correct |
34 ms |
9176 KB |
Output is correct |
4 |
Correct |
39 ms |
9932 KB |
Output is correct |
5 |
Correct |
43 ms |
10704 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
43 ms |
15040 KB |
Output is correct |
2 |
Correct |
38 ms |
7124 KB |
Output is correct |
3 |
Correct |
41 ms |
13632 KB |
Output is correct |
4 |
Correct |
56 ms |
12320 KB |
Output is correct |
5 |
Correct |
33 ms |
4248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
44 ms |
7368 KB |
Output is correct |
2 |
Correct |
43 ms |
7112 KB |
Output is correct |
3 |
Correct |
37 ms |
4692 KB |
Output is correct |
4 |
Correct |
52 ms |
12232 KB |
Output is correct |
5 |
Correct |
49 ms |
10400 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
14148 KB |
Output is correct |
2 |
Correct |
45 ms |
7112 KB |
Output is correct |
3 |
Correct |
36 ms |
4812 KB |
Output is correct |
4 |
Correct |
47 ms |
12232 KB |
Output is correct |
5 |
Correct |
51 ms |
10440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
263 ms |
74420 KB |
Output is correct |
2 |
Correct |
168 ms |
16368 KB |
Output is correct |
3 |
Correct |
167 ms |
15884 KB |
Output is correct |
4 |
Correct |
303 ms |
56512 KB |
Output is correct |
5 |
Correct |
255 ms |
43196 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
171 ms |
16812 KB |
Output is correct |
2 |
Correct |
265 ms |
55712 KB |
Output is correct |
3 |
Correct |
235 ms |
27084 KB |
Output is correct |
4 |
Correct |
277 ms |
56388 KB |
Output is correct |
5 |
Correct |
270 ms |
51652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
293 ms |
103844 KB |
Output is correct |
2 |
Correct |
177 ms |
18884 KB |
Output is correct |
3 |
Correct |
178 ms |
18356 KB |
Output is correct |
4 |
Correct |
325 ms |
74600 KB |
Output is correct |
5 |
Correct |
288 ms |
44732 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
181 ms |
19536 KB |
Output is correct |
2 |
Correct |
305 ms |
70840 KB |
Output is correct |
3 |
Correct |
253 ms |
26308 KB |
Output is correct |
4 |
Correct |
336 ms |
74436 KB |
Output is correct |
5 |
Correct |
323 ms |
67596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
364 ms |
117296 KB |
Output is correct |
2 |
Correct |
199 ms |
21968 KB |
Output is correct |
3 |
Correct |
201 ms |
21336 KB |
Output is correct |
4 |
Correct |
386 ms |
84160 KB |
Output is correct |
5 |
Correct |
326 ms |
44740 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
213 ms |
22608 KB |
Output is correct |
2 |
Correct |
363 ms |
79800 KB |
Output is correct |
3 |
Correct |
327 ms |
35832 KB |
Output is correct |
4 |
Correct |
381 ms |
83964 KB |
Output is correct |
5 |
Correct |
364 ms |
73920 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
400 ms |
129580 KB |
Output is correct |
2 |
Correct |
215 ms |
23380 KB |
Output is correct |
3 |
Correct |
213 ms |
22612 KB |
Output is correct |
4 |
Correct |
427 ms |
91840 KB |
Output is correct |
5 |
Correct |
419 ms |
61380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
225 ms |
23848 KB |
Output is correct |
2 |
Correct |
411 ms |
87224 KB |
Output is correct |
3 |
Correct |
362 ms |
36488 KB |
Output is correct |
4 |
Correct |
430 ms |
91580 KB |
Output is correct |
5 |
Correct |
421 ms |
80576 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
445 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
278 ms |
29560 KB |
Output is correct |
2 |
Correct |
532 ms |
108056 KB |
Output is correct |
3 |
Correct |
484 ms |
49084 KB |
Output is correct |
4 |
Correct |
571 ms |
110268 KB |
Output is correct |
5 |
Correct |
517 ms |
96612 KB |
Output is correct |