// time-limit: 3000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double eps = 1E-4;
struct point {
int x{}, y{};
};
void solve() {
int n, L;
cin >> n >> L;
vector<point> p(n);
for(int i = 0; i < n; i++) {
cin >> p[i].x >> p[i].y;
}
auto intersection = [&](const point& A, double R) -> array<double, 2> {
if(abs(A.y) > R) {
return {L, -1};
}
double D = 1.0 * R * R - 1.0 * A.y * A.y; // divided by 4
double x1 = A.x - sqrt(D);
double x2 = A.x + sqrt(D);
if(x2 < x1) swap(x1, x2);
return {x1, x2};
};
auto good = [&](double R) {
vector<array<double, 2>> segs(n);
for(int i = 0; i < n; i++) {
segs[i] = intersection(p[i], R);
}
sort(segs.begin(), segs.end());
double l = segs[0][0], r = segs[0][1];
int i = 0;
while(i + 1 < n && segs[i + 1][0] <= r) {
r = max(segs[i + 1][1], r);
i++;
}
return r >= L && l <= 0;
};
double l = 0, r = 4e9;
while(r - l > eps) {
double R = (r + l) / 2;
if(good(R)) {
r = R;
}
else {
l = R;
}
}
cout << fixed << setprecision(-log10(eps)) << r << endl;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
double T = 1;
//cin >> T;
while(T--) solve();
return 0;
}
Compilation message
mobile.cpp: In lambda function:
mobile.cpp:23:21: warning: narrowing conversion of 'L' from 'int' to 'double' [-Wnarrowing]
23 | return {L, -1};
| ^
# |
결과 |
실행 시간 |
메모리 |
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 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Incorrect |
4 ms |
504 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
348 KB |
Output is correct |
2 |
Correct |
5 ms |
348 KB |
Output is correct |
3 |
Correct |
7 ms |
568 KB |
Output is correct |
4 |
Correct |
8 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
568 KB |
Output is correct |
2 |
Correct |
5 ms |
572 KB |
Output is correct |
3 |
Correct |
7 ms |
572 KB |
Output is correct |
4 |
Correct |
8 ms |
344 KB |
Output is correct |
5 |
Correct |
9 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
146 ms |
2200 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
145 ms |
2192 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
104 ms |
2396 KB |
Output is correct |
2 |
Correct |
175 ms |
2392 KB |
Output is correct |
3 |
Correct |
199 ms |
2432 KB |
Output is correct |
4 |
Incorrect |
192 ms |
2780 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
176 ms |
2652 KB |
Output is correct |
2 |
Correct |
233 ms |
2652 KB |
Output is correct |
3 |
Correct |
212 ms |
2652 KB |
Output is correct |
4 |
Correct |
188 ms |
2788 KB |
Output is correct |
5 |
Incorrect |
206 ms |
2652 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
124 ms |
2792 KB |
Output is correct |
2 |
Correct |
233 ms |
2652 KB |
Output is correct |
3 |
Correct |
238 ms |
2652 KB |
Output is correct |
4 |
Correct |
188 ms |
2652 KB |
Output is correct |
5 |
Incorrect |
196 ms |
2648 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
634 ms |
12188 KB |
Output is correct |
2 |
Execution timed out |
1044 ms |
12176 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1060 ms |
12116 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
796 ms |
14532 KB |
Output is correct |
2 |
Execution timed out |
1027 ms |
14512 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1050 ms |
14472 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1018 ms |
16888 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1071 ms |
16744 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1070 ms |
19068 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1071 ms |
19052 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1004 ms |
23888 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1076 ms |
23892 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |