#include <bits/stdc++.h>
#define ll long long
using namespace std;
bool check(double maxDist, vector<pair<double, double>> &transceivers, ll N, ll L) {
vector<pair<double, double>> bounds;
double covered = 0;
for (int i = 0; i < N; i++) {
double ySquared = transceivers[i].second * transceivers[i].second;
double hypoSquared = maxDist * maxDist;
if (hypoSquared - ySquared < 0) {
continue;
}
double x = sqrt(hypoSquared - ySquared);
// if (transceivers[i].first - x <= covered) {
// covered = max(covered, transceivers[i].first + x);
// }
bounds.push_back({ transceivers[i].first - x, transceivers[i].first + x });
}
for (int i = 0; i < (int)bounds.size(); i++) {
if (bounds[i].first <= covered) {
covered = max(covered, bounds[i].second);
}
}
return covered >= (double)L;
}
int main() {
ll N, L;
cin >> N >> L;
vector<pair<double, double>> transceivers(N);
for (int i = 0; i < N; i++) cin >> transceivers[i].first >> transceivers[i].second;
double l = 0;
double r = 1e18;
double ans = 0;
while (r - l >= 0.001) {
double mid = l + (r - l) / 2;
// cout << l << ' ' << r << ' ' << mid << '\n';
if (check(mid, transceivers, N, L)) {
r = mid;
ans = mid;
} else {
l = mid;
}
}
printf("%0.7lf\n", ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
332 KB |
Output is correct |
2 |
Correct |
5 ms |
332 KB |
Output is correct |
3 |
Correct |
4 ms |
332 KB |
Output is correct |
4 |
Correct |
5 ms |
428 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
740 KB |
Output is correct |
2 |
Correct |
13 ms |
572 KB |
Output is correct |
3 |
Correct |
10 ms |
572 KB |
Output is correct |
4 |
Correct |
10 ms |
580 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
572 KB |
Output is correct |
2 |
Correct |
13 ms |
588 KB |
Output is correct |
3 |
Correct |
10 ms |
572 KB |
Output is correct |
4 |
Correct |
13 ms |
572 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
816 KB |
Output is correct |
2 |
Correct |
12 ms |
828 KB |
Output is correct |
3 |
Correct |
11 ms |
748 KB |
Output is correct |
4 |
Correct |
11 ms |
572 KB |
Output is correct |
5 |
Correct |
10 ms |
572 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
198 ms |
4824 KB |
Output is correct |
2 |
Correct |
230 ms |
4944 KB |
Output is correct |
3 |
Correct |
146 ms |
3100 KB |
Output is correct |
4 |
Correct |
168 ms |
4804 KB |
Output is correct |
5 |
Correct |
103 ms |
2872 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
201 ms |
4892 KB |
Output is correct |
2 |
Correct |
156 ms |
4676 KB |
Output is correct |
3 |
Correct |
190 ms |
4968 KB |
Output is correct |
4 |
Correct |
178 ms |
4904 KB |
Output is correct |
5 |
Correct |
208 ms |
5160 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
221 ms |
5192 KB |
Output is correct |
2 |
Correct |
252 ms |
5088 KB |
Output is correct |
3 |
Correct |
201 ms |
5072 KB |
Output is correct |
4 |
Correct |
226 ms |
5520 KB |
Output is correct |
5 |
Correct |
201 ms |
5348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
305 ms |
5560 KB |
Output is correct |
2 |
Correct |
282 ms |
5692 KB |
Output is correct |
3 |
Correct |
255 ms |
5532 KB |
Output is correct |
4 |
Correct |
227 ms |
5588 KB |
Output is correct |
5 |
Correct |
216 ms |
5588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
310 ms |
5588 KB |
Output is correct |
2 |
Correct |
281 ms |
5644 KB |
Output is correct |
3 |
Correct |
285 ms |
5564 KB |
Output is correct |
4 |
Correct |
220 ms |
5560 KB |
Output is correct |
5 |
Correct |
222 ms |
5532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1084 ms |
24324 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1071 ms |
24316 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1063 ms |
35596 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1080 ms |
35544 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1081 ms |
38728 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1092 ms |
38696 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1079 ms |
41796 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1085 ms |
41744 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1075 ms |
48128 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1081 ms |
15948 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |