#include <bits/stdc++.h>
#define long long long
using namespace std;
const int N = (int) 1E6;
int n, k;
int x[N], y[N];
/*
为什么这么做的对的,考虑排序线段。
我们排序线段的目的就是为了 连的上!
所以如果线段 i 在 j 之后出现
且 l(i) < l(j)
一定有 r(i) > r(j),这就保证了我们不需要使用排序
*/
bool valid(double a) {
double t = 0;
// t 表示已经可以覆盖 [0, t] 了,初始为空区间
// 因为输入的点的坐标是有序的,所以如果当前的 r 只能覆盖线段
// 的中段的话,t 还会保持是 0
for (int i = 0; i < n; i++) {
if (a < y[i]) {
continue;
}
double l = x[i] - sqrt(1.0 * a * a - 1.0 * y[i] * y[i]);
// 直接 y[i] * y[i] 可能会爆
// 同时,由于 r 大于最大的 abs(y[i]),所以不会出现 sqrt 负数的情况
double r = x[i] + sqrt(1.0 * a * a - 1.0 * y[i] * y[i]);
if (l <= t && r >= t) {
t = r;
}
}
return t >= k;
}
void solve() {
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> x[i] >> y[i];
}
double l = 0, r = 2E9;
for (int i = 0; i < 100; i++) {
double m = (l + r) / 2;
if (valid(m)) {
r = m;
} else {
l = m;
}
}
cout << fixed << setprecision(6);
cout << r << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
t = 1;
for (int i = 0; i < t; i++) {
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2396 KB |
Output is correct |
2 |
Correct |
2 ms |
2568 KB |
Output is correct |
3 |
Correct |
2 ms |
2396 KB |
Output is correct |
4 |
Correct |
3 ms |
2600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2396 KB |
Output is correct |
2 |
Correct |
3 ms |
2396 KB |
Output is correct |
3 |
Correct |
2 ms |
2396 KB |
Output is correct |
4 |
Correct |
3 ms |
2392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2396 KB |
Output is correct |
2 |
Correct |
2 ms |
2524 KB |
Output is correct |
3 |
Correct |
2 ms |
2392 KB |
Output is correct |
4 |
Correct |
3 ms |
2616 KB |
Output is correct |
5 |
Correct |
2 ms |
2572 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
4700 KB |
Output is correct |
2 |
Correct |
26 ms |
5720 KB |
Output is correct |
3 |
Correct |
21 ms |
5368 KB |
Output is correct |
4 |
Correct |
68 ms |
5724 KB |
Output is correct |
5 |
Correct |
19 ms |
4956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
4696 KB |
Output is correct |
2 |
Correct |
61 ms |
5532 KB |
Output is correct |
3 |
Correct |
73 ms |
5720 KB |
Output is correct |
4 |
Correct |
71 ms |
5720 KB |
Output is correct |
5 |
Correct |
80 ms |
5952 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
4700 KB |
Output is correct |
2 |
Correct |
30 ms |
4700 KB |
Output is correct |
3 |
Correct |
26 ms |
4700 KB |
Output is correct |
4 |
Correct |
95 ms |
7040 KB |
Output is correct |
5 |
Correct |
61 ms |
5448 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
6748 KB |
Output is correct |
2 |
Correct |
50 ms |
6792 KB |
Output is correct |
3 |
Correct |
29 ms |
6748 KB |
Output is correct |
4 |
Correct |
105 ms |
6748 KB |
Output is correct |
5 |
Correct |
101 ms |
7932 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
43 ms |
6780 KB |
Output is correct |
2 |
Correct |
37 ms |
8184 KB |
Output is correct |
3 |
Correct |
30 ms |
7816 KB |
Output is correct |
4 |
Correct |
98 ms |
8540 KB |
Output is correct |
5 |
Correct |
89 ms |
8052 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
168 ms |
6772 KB |
Output is correct |
2 |
Correct |
223 ms |
14328 KB |
Output is correct |
3 |
Correct |
174 ms |
13780 KB |
Output is correct |
4 |
Correct |
484 ms |
16208 KB |
Output is correct |
5 |
Correct |
458 ms |
13392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
186 ms |
6776 KB |
Output is correct |
2 |
Correct |
309 ms |
13388 KB |
Output is correct |
3 |
Correct |
143 ms |
12372 KB |
Output is correct |
4 |
Correct |
478 ms |
15956 KB |
Output is correct |
5 |
Correct |
452 ms |
13908 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
196 ms |
6744 KB |
Output is correct |
2 |
Correct |
239 ms |
15996 KB |
Output is correct |
3 |
Correct |
208 ms |
15360 KB |
Output is correct |
4 |
Correct |
601 ms |
18688 KB |
Output is correct |
5 |
Correct |
541 ms |
14676 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
210 ms |
6748 KB |
Output is correct |
2 |
Correct |
353 ms |
14708 KB |
Output is correct |
3 |
Correct |
169 ms |
13396 KB |
Output is correct |
4 |
Correct |
616 ms |
18516 KB |
Output is correct |
5 |
Correct |
531 ms |
15508 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
225 ms |
6996 KB |
Output is correct |
2 |
Correct |
241 ms |
17744 KB |
Output is correct |
3 |
Correct |
242 ms |
17236 KB |
Output is correct |
4 |
Correct |
664 ms |
20564 KB |
Output is correct |
5 |
Correct |
655 ms |
15956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
248 ms |
7088 KB |
Output is correct |
2 |
Correct |
384 ms |
16352 KB |
Output is correct |
3 |
Correct |
206 ms |
15444 KB |
Output is correct |
4 |
Correct |
672 ms |
20348 KB |
Output is correct |
5 |
Correct |
630 ms |
17240 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
261 ms |
7480 KB |
Output is correct |
2 |
Correct |
306 ms |
20048 KB |
Output is correct |
3 |
Correct |
281 ms |
18940 KB |
Output is correct |
4 |
Correct |
772 ms |
22916 KB |
Output is correct |
5 |
Correct |
725 ms |
18648 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
293 ms |
7400 KB |
Output is correct |
2 |
Correct |
405 ms |
18256 KB |
Output is correct |
3 |
Correct |
238 ms |
17232 KB |
Output is correct |
4 |
Correct |
789 ms |
22776 KB |
Output is correct |
5 |
Correct |
736 ms |
19280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
357 ms |
8020 KB |
Output is correct |
2 |
Correct |
349 ms |
23636 KB |
Output is correct |
3 |
Correct |
344 ms |
22688 KB |
Output is correct |
4 |
Correct |
960 ms |
27488 KB |
Output is correct |
5 |
Correct |
854 ms |
21848 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
348 ms |
8024 KB |
Output is correct |
2 |
Correct |
492 ms |
21584 KB |
Output is correct |
3 |
Correct |
289 ms |
20560 KB |
Output is correct |
4 |
Correct |
960 ms |
27628 KB |
Output is correct |
5 |
Correct |
916 ms |
23028 KB |
Output is correct |