#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#ifndef ONLINE_JUDGE
#define DEBUG(x) cout << #x << " = " << (x) << endl
#else
#define DEBUG(x)
#endif
#define FOR(n) for(int i = 0; i < (n); i++)
#define SORTA(v) sort((v).begin(), (v).end())
#define SORTD(v) sort((v).rbegin(), (v).rend())
#define PRINT(v) for(auto x: (v))cout << x << " "; cout << endl;
#define TWO(n) (1 << (n))
#define INPUT(v) for(auto &x : (v))cin >> x;
typedef long long ll;
using namespace std;
vector<pair<double, double>> torri;
ll n, L;
// Function to calculate horizontal width
double get_hw(double y, double r) {
if (abs(y) > r - 1e-6) return -1.0;
return sqrt((r - y) * (r + y));
}
// Check if given radius R can cover the highway
bool good(double R) {
double progress = 0.0;
for (int i = 0; i < n; i++) {
double x = torri[i].first, y = torri[i].second;
double hw = get_hw(y, R); // Horizontal width
if (hw < 0) continue; // Station doesn't reach the highway
double left = x - hw;
double right = x + hw;
if (left <= progress + 1e-6) {
progress = max(progress, right);
}
if (progress >= L) return true; // Exit early if highway is covered
}
return false;
}
void solve() {
cin >> n >> L;
torri = vector<pair<double, double>>(n);
for (int i = 0; i < n; i++) {
cin >> torri[i].first >> torri[i].second;
}
double l = 1, r = 2e9; // Adjust upper bound based on problem limits
double ans = r;
while (r - l > 1e-6) { // Adjust precision for better accuracy
double c = (r + l) / 2;
if (good(c)) {
ans = c;
r = c;
} else {
l = c;
}
}
cout << setprecision(18) << (l + r) / 2 << endl; // Output with high precision
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
Compilation message
mobile.cpp: In function 'void solve()':
mobile.cpp:56:12: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
56 | double ans = r;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
460 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 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
604 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
604 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
608 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
352 KB |
Output is correct |
2 |
Correct |
2 ms |
600 KB |
Output is correct |
3 |
Correct |
2 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
2396 KB |
Output is correct |
2 |
Correct |
26 ms |
2652 KB |
Output is correct |
3 |
Correct |
17 ms |
1924 KB |
Output is correct |
4 |
Correct |
26 ms |
2788 KB |
Output is correct |
5 |
Correct |
15 ms |
1624 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
2396 KB |
Output is correct |
2 |
Correct |
24 ms |
2140 KB |
Output is correct |
3 |
Correct |
26 ms |
2764 KB |
Output is correct |
4 |
Correct |
27 ms |
2720 KB |
Output is correct |
5 |
Correct |
32 ms |
3156 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
2344 KB |
Output is correct |
2 |
Correct |
29 ms |
2892 KB |
Output is correct |
3 |
Correct |
26 ms |
2648 KB |
Output is correct |
4 |
Correct |
41 ms |
3944 KB |
Output is correct |
5 |
Correct |
28 ms |
2620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
3420 KB |
Output is correct |
2 |
Correct |
35 ms |
3420 KB |
Output is correct |
3 |
Correct |
31 ms |
2908 KB |
Output is correct |
4 |
Correct |
49 ms |
3920 KB |
Output is correct |
5 |
Correct |
32 ms |
3044 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
43 ms |
3420 KB |
Output is correct |
2 |
Correct |
37 ms |
3412 KB |
Output is correct |
3 |
Correct |
31 ms |
2908 KB |
Output is correct |
4 |
Correct |
41 ms |
3796 KB |
Output is correct |
5 |
Correct |
34 ms |
3152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
188 ms |
12368 KB |
Output is correct |
2 |
Correct |
205 ms |
15952 KB |
Output is correct |
3 |
Correct |
167 ms |
15440 KB |
Output is correct |
4 |
Correct |
200 ms |
17748 KB |
Output is correct |
5 |
Correct |
173 ms |
14936 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
234 ms |
16468 KB |
Output is correct |
2 |
Correct |
276 ms |
14664 KB |
Output is correct |
3 |
Correct |
162 ms |
13908 KB |
Output is correct |
4 |
Correct |
190 ms |
17492 KB |
Output is correct |
5 |
Correct |
179 ms |
15572 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
225 ms |
14932 KB |
Output is correct |
2 |
Correct |
240 ms |
18908 KB |
Output is correct |
3 |
Correct |
202 ms |
18516 KB |
Output is correct |
4 |
Correct |
223 ms |
21588 KB |
Output is correct |
5 |
Correct |
194 ms |
17760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
230 ms |
19544 KB |
Output is correct |
2 |
Correct |
300 ms |
17756 KB |
Output is correct |
3 |
Correct |
185 ms |
16856 KB |
Output is correct |
4 |
Correct |
224 ms |
21468 KB |
Output is correct |
5 |
Correct |
202 ms |
18512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
250 ms |
17400 KB |
Output is correct |
2 |
Correct |
251 ms |
22016 KB |
Output is correct |
3 |
Correct |
257 ms |
21372 KB |
Output is correct |
4 |
Correct |
263 ms |
24700 KB |
Output is correct |
5 |
Correct |
234 ms |
20304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
272 ms |
22908 KB |
Output is correct |
2 |
Correct |
344 ms |
20560 KB |
Output is correct |
3 |
Correct |
239 ms |
19540 KB |
Output is correct |
4 |
Correct |
276 ms |
24656 KB |
Output is correct |
5 |
Correct |
247 ms |
21500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
298 ms |
19896 KB |
Output is correct |
2 |
Correct |
294 ms |
25168 KB |
Output is correct |
3 |
Correct |
287 ms |
24556 KB |
Output is correct |
4 |
Correct |
350 ms |
28496 KB |
Output is correct |
5 |
Correct |
275 ms |
23968 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
297 ms |
26012 KB |
Output is correct |
2 |
Correct |
380 ms |
23348 KB |
Output is correct |
3 |
Correct |
250 ms |
22356 KB |
Output is correct |
4 |
Correct |
294 ms |
28240 KB |
Output is correct |
5 |
Correct |
263 ms |
24344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
358 ms |
24660 KB |
Output is correct |
2 |
Correct |
336 ms |
31572 KB |
Output is correct |
3 |
Correct |
320 ms |
30548 KB |
Output is correct |
4 |
Correct |
384 ms |
35160 KB |
Output is correct |
5 |
Correct |
344 ms |
29524 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
423 ms |
32336 KB |
Output is correct |
2 |
Correct |
480 ms |
29264 KB |
Output is correct |
3 |
Correct |
365 ms |
28264 KB |
Output is correct |
4 |
Correct |
389 ms |
35408 KB |
Output is correct |
5 |
Correct |
352 ms |
30804 KB |
Output is correct |