#include <bits/stdc++.h>
#define ll long long
using namespace std;
bool check(double maxDist, vector<pair<double, double>> &transceivers, ll N, ll L) {
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);
}
}
return covered >= 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 = 1e9;
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.4lf\n", ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 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 |
3 ms |
332 KB |
Output is correct |
2 |
Correct |
4 ms |
204 KB |
Output is correct |
3 |
Correct |
3 ms |
204 KB |
Output is correct |
4 |
Correct |
4 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
332 KB |
Output is correct |
2 |
Correct |
7 ms |
332 KB |
Output is correct |
3 |
Correct |
5 ms |
332 KB |
Output is correct |
4 |
Correct |
7 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
332 KB |
Output is correct |
2 |
Correct |
7 ms |
364 KB |
Output is correct |
3 |
Correct |
5 ms |
332 KB |
Output is correct |
4 |
Correct |
7 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
332 KB |
Output is correct |
2 |
Correct |
7 ms |
332 KB |
Output is correct |
3 |
Correct |
5 ms |
332 KB |
Output is correct |
4 |
Correct |
7 ms |
368 KB |
Output is correct |
5 |
Correct |
6 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
84 ms |
1356 KB |
Output is correct |
2 |
Correct |
115 ms |
1488 KB |
Output is correct |
3 |
Correct |
71 ms |
1100 KB |
Output is correct |
4 |
Correct |
101 ms |
1356 KB |
Output is correct |
5 |
Correct |
43 ms |
972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
78 ms |
1508 KB |
Output is correct |
2 |
Correct |
85 ms |
1396 KB |
Output is correct |
3 |
Correct |
96 ms |
1484 KB |
Output is correct |
4 |
Correct |
105 ms |
1484 KB |
Output is correct |
5 |
Correct |
124 ms |
1636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
90 ms |
1612 KB |
Output is correct |
2 |
Correct |
124 ms |
1572 KB |
Output is correct |
3 |
Correct |
95 ms |
1612 KB |
Output is correct |
4 |
Correct |
150 ms |
1840 KB |
Output is correct |
5 |
Correct |
95 ms |
1612 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
132 ms |
1740 KB |
Output is correct |
2 |
Correct |
125 ms |
1740 KB |
Output is correct |
3 |
Correct |
106 ms |
1740 KB |
Output is correct |
4 |
Correct |
150 ms |
1848 KB |
Output is correct |
5 |
Correct |
116 ms |
1844 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
132 ms |
1848 KB |
Output is correct |
2 |
Correct |
129 ms |
1848 KB |
Output is correct |
3 |
Correct |
107 ms |
1740 KB |
Output is correct |
4 |
Correct |
159 ms |
1740 KB |
Output is correct |
5 |
Correct |
120 ms |
1740 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
510 ms |
8112 KB |
Output is correct |
2 |
Correct |
647 ms |
8128 KB |
Output is correct |
3 |
Correct |
657 ms |
8116 KB |
Output is correct |
4 |
Correct |
732 ms |
8132 KB |
Output is correct |
5 |
Correct |
612 ms |
8108 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
661 ms |
8132 KB |
Output is correct |
2 |
Correct |
667 ms |
8132 KB |
Output is correct |
3 |
Correct |
547 ms |
8116 KB |
Output is correct |
4 |
Correct |
714 ms |
8124 KB |
Output is correct |
5 |
Correct |
624 ms |
8112 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
610 ms |
9676 KB |
Output is correct |
2 |
Correct |
783 ms |
9796 KB |
Output is correct |
3 |
Correct |
753 ms |
9684 KB |
Output is correct |
4 |
Correct |
892 ms |
9692 KB |
Output is correct |
5 |
Correct |
728 ms |
9796 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
825 ms |
9676 KB |
Output is correct |
2 |
Correct |
774 ms |
9676 KB |
Output is correct |
3 |
Correct |
670 ms |
9796 KB |
Output is correct |
4 |
Correct |
901 ms |
9676 KB |
Output is correct |
5 |
Correct |
741 ms |
9796 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
708 ms |
11212 KB |
Output is correct |
2 |
Correct |
950 ms |
11248 KB |
Output is correct |
3 |
Correct |
887 ms |
11244 KB |
Output is correct |
4 |
Execution timed out |
1041 ms |
11236 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
945 ms |
11236 KB |
Output is correct |
2 |
Correct |
898 ms |
11240 KB |
Output is correct |
3 |
Correct |
792 ms |
11244 KB |
Output is correct |
4 |
Execution timed out |
1010 ms |
11332 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
785 ms |
12816 KB |
Output is correct |
2 |
Execution timed out |
1039 ms |
12808 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1088 ms |
12804 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1006 ms |
15948 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1093 ms |
16076 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |