#include <bits/stdc++.h>
#define int long long
using i64 = long long;
using ld = long double;
ld cross(std::pair<int, int> a, std::pair<int, int> b) {
int x1 = a.first, x2 = b.first, y1 = a.second, y2 = b.second;
return 1.0 * (1ll * x2 * x2 + y2 * y2 - 1ll * x1 * x1 - 1ll * y1 * y1) / (2.0 * (x2 - x1));
}
ld solve(ld s, ld e, std::pair<int, int> t) {
return std::max(std::hypot(s - t.first, t.second), std::hypot(e - t.first, t.second));
}
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout << std::fixed << std::setprecision(3);
int n, L;
std::cin >> n >> L;
std::vector<std::pair<int, int>> a(n);
for (int i = 0; i < n; i++) {
std::cin >> a[i].first >> a[i].second;
a[i].second = abs(a[i].second);
}
std::sort(a.begin(), a.end());
std::deque<std::pair<int, int>> st;
for (int i = 0; i < n; i++) {
int j = i;
while (j < n && a[j].first == a[i].first) {
j++;
}
while (st.size() >= 2 && cross(st[st.size() - 2], st.back()) > cross(st.back(), a[i])) {
st.pop_back();
}
st.push_back(a[i]);
i = j - 1;
}
ld answer = 0;
while (st.size() >= 2 && cross(st[0], st[1]) < 0) {
st.pop_front();
}
while (st.size() >= 2 && cross(st[st.size() - 2], st.back()) > L) {
st.pop_back();
}
answer = std::max(answer, solve(0, cross(st[0], st[1]), st[0]));
answer = std::max(answer, solve(cross(st[st.size() - 2], st.back()), L, st.back()));
for (int i = 1; i < st.size() - 1; i++) {
answer = std::max(answer, solve(cross(st[i - 1], st[i]), cross(st[i], st[i + 1]), st[i]));
}
answer = (ld) ((ld) ((ld) answer * (int) 1e3) / (int) 1e3);
std::cout << answer << "\n";
return 0;
}
Compilation message
mobile.cpp: In function 'int main()':
mobile.cpp:52:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::deque<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | for (int i = 1; i < st.size() - 1; i++) {
| ~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
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 |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
548 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
1624 KB |
Output is correct |
2 |
Correct |
12 ms |
1628 KB |
Output is correct |
3 |
Correct |
9 ms |
1884 KB |
Output is correct |
4 |
Correct |
15 ms |
2784 KB |
Output is correct |
5 |
Correct |
7 ms |
1556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
1624 KB |
Output is correct |
2 |
Correct |
12 ms |
1368 KB |
Output is correct |
3 |
Correct |
14 ms |
1628 KB |
Output is correct |
4 |
Correct |
17 ms |
2848 KB |
Output is correct |
5 |
Correct |
18 ms |
3164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
3360 KB |
Output is correct |
2 |
Correct |
15 ms |
1628 KB |
Output is correct |
3 |
Correct |
17 ms |
3928 KB |
Output is correct |
4 |
Correct |
22 ms |
3936 KB |
Output is correct |
5 |
Correct |
14 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1884 KB |
Output is correct |
2 |
Correct |
17 ms |
3428 KB |
Output is correct |
3 |
Correct |
15 ms |
3164 KB |
Output is correct |
4 |
Correct |
21 ms |
4184 KB |
Output is correct |
5 |
Correct |
18 ms |
3164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
2904 KB |
Output is correct |
2 |
Correct |
19 ms |
1912 KB |
Output is correct |
3 |
Correct |
15 ms |
3164 KB |
Output is correct |
4 |
Correct |
21 ms |
3796 KB |
Output is correct |
5 |
Correct |
18 ms |
3160 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
127 ms |
16608 KB |
Output is correct |
2 |
Correct |
78 ms |
8284 KB |
Output is correct |
3 |
Correct |
76 ms |
8284 KB |
Output is correct |
4 |
Correct |
97 ms |
8284 KB |
Output is correct |
5 |
Correct |
89 ms |
14932 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
85 ms |
8284 KB |
Output is correct |
2 |
Correct |
81 ms |
9048 KB |
Output is correct |
3 |
Correct |
71 ms |
9808 KB |
Output is correct |
4 |
Correct |
99 ms |
17496 KB |
Output is correct |
5 |
Correct |
88 ms |
15448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
143 ms |
19684 KB |
Output is correct |
2 |
Correct |
93 ms |
9816 KB |
Output is correct |
3 |
Correct |
90 ms |
9836 KB |
Output is correct |
4 |
Correct |
124 ms |
10068 KB |
Output is correct |
5 |
Correct |
104 ms |
17748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
9816 KB |
Output is correct |
2 |
Correct |
97 ms |
10608 KB |
Output is correct |
3 |
Correct |
80 ms |
10836 KB |
Output is correct |
4 |
Correct |
120 ms |
9848 KB |
Output is correct |
5 |
Correct |
109 ms |
18532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
170 ms |
22752 KB |
Output is correct |
2 |
Correct |
126 ms |
11404 KB |
Output is correct |
3 |
Correct |
108 ms |
11404 KB |
Output is correct |
4 |
Correct |
137 ms |
11404 KB |
Output is correct |
5 |
Correct |
118 ms |
20240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
115 ms |
11356 KB |
Output is correct |
2 |
Correct |
115 ms |
12176 KB |
Output is correct |
3 |
Correct |
101 ms |
13396 KB |
Output is correct |
4 |
Correct |
143 ms |
24660 KB |
Output is correct |
5 |
Correct |
130 ms |
21936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
191 ms |
26104 KB |
Output is correct |
2 |
Correct |
131 ms |
12972 KB |
Output is correct |
3 |
Correct |
123 ms |
12888 KB |
Output is correct |
4 |
Correct |
161 ms |
12976 KB |
Output is correct |
5 |
Correct |
141 ms |
24148 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
130 ms |
12892 KB |
Output is correct |
2 |
Correct |
129 ms |
14000 KB |
Output is correct |
3 |
Correct |
113 ms |
14764 KB |
Output is correct |
4 |
Correct |
163 ms |
28240 KB |
Output is correct |
5 |
Correct |
141 ms |
24436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
242 ms |
32504 KB |
Output is correct |
2 |
Correct |
159 ms |
15964 KB |
Output is correct |
3 |
Correct |
151 ms |
16100 KB |
Output is correct |
4 |
Correct |
204 ms |
35152 KB |
Output is correct |
5 |
Correct |
174 ms |
29560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
168 ms |
15960 KB |
Output is correct |
2 |
Correct |
162 ms |
17128 KB |
Output is correct |
3 |
Correct |
153 ms |
18516 KB |
Output is correct |
4 |
Correct |
204 ms |
35468 KB |
Output is correct |
5 |
Correct |
200 ms |
30544 KB |
Output is correct |