#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<pair<double, double>> torri;
ll n, L;
bool good(double r) {
queue<pair<double, double>> q;
double curr = 0;
for (auto a : torri) {
double x = a.first, y = a.second;
if(curr >= L)return true;
if (abs(y) <= r - 1e-6) {
double dx = sqrt((r + y) * (r - y));
double a = x-dx, b = x+dx;
q.push({a,b});
}
}
while (!q.empty()) {
if (curr >= L) return true;
auto seg = q.front();
q.pop();
if (seg.first-1e-6 <= curr) {
curr = max(seg.second, curr);
}
}
return curr >= L;
}
void solve() {
cin >> n >> L;
torri.resize(n);
for (int i = 0; i < n; i++) {
cin >> torri[i].first >> torri[i].second;
}
double l = 1, r = 2e9;
double ans = r;
while (r - l > 1e-4) {
double c = (r + l) / 2;
if (good(c)) {
ans = c;
r = c;
} else {
l = c;
}
}
cout << setprecision(18) << (l + r) / 2 << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
Compilation message
mobile.cpp: In function 'void solve()':
mobile.cpp:41:12: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
41 | double ans = r;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 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 |
Correct |
1 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 |
1 ms |
436 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
604 KB |
Output is correct |
2 |
Correct |
3 ms |
600 KB |
Output is correct |
3 |
Correct |
2 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
600 KB |
Output is correct |
2 |
Correct |
3 ms |
468 KB |
Output is correct |
3 |
Correct |
2 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
600 KB |
Output is correct |
2 |
Correct |
3 ms |
464 KB |
Output is correct |
3 |
Correct |
3 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
3 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
3604 KB |
Output is correct |
2 |
Correct |
49 ms |
4112 KB |
Output is correct |
3 |
Correct |
30 ms |
2816 KB |
Output is correct |
4 |
Correct |
32 ms |
4080 KB |
Output is correct |
5 |
Correct |
22 ms |
2468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
35 ms |
3716 KB |
Output is correct |
2 |
Correct |
33 ms |
3524 KB |
Output is correct |
3 |
Correct |
46 ms |
4088 KB |
Output is correct |
4 |
Correct |
48 ms |
4160 KB |
Output is correct |
5 |
Correct |
37 ms |
4688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
54 ms |
4088 KB |
Output is correct |
2 |
Correct |
53 ms |
4400 KB |
Output is correct |
3 |
Correct |
45 ms |
4128 KB |
Output is correct |
4 |
Correct |
42 ms |
5548 KB |
Output is correct |
5 |
Correct |
39 ms |
4264 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
68 ms |
5312 KB |
Output is correct |
2 |
Correct |
63 ms |
5228 KB |
Output is correct |
3 |
Correct |
58 ms |
4720 KB |
Output is correct |
4 |
Correct |
46 ms |
5592 KB |
Output is correct |
5 |
Correct |
43 ms |
4956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
66 ms |
5276 KB |
Output is correct |
2 |
Correct |
65 ms |
5420 KB |
Output is correct |
3 |
Correct |
71 ms |
4700 KB |
Output is correct |
4 |
Correct |
49 ms |
5524 KB |
Output is correct |
5 |
Correct |
55 ms |
4940 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
324 ms |
20848 KB |
Output is correct |
2 |
Correct |
432 ms |
24368 KB |
Output is correct |
3 |
Correct |
355 ms |
23776 KB |
Output is correct |
4 |
Correct |
209 ms |
26224 KB |
Output is correct |
5 |
Correct |
225 ms |
23428 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
366 ms |
24944 KB |
Output is correct |
2 |
Correct |
338 ms |
23108 KB |
Output is correct |
3 |
Correct |
346 ms |
22180 KB |
Output is correct |
4 |
Correct |
204 ms |
25744 KB |
Output is correct |
5 |
Correct |
219 ms |
23780 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
445 ms |
24940 KB |
Output is correct |
2 |
Correct |
413 ms |
29044 KB |
Output is correct |
3 |
Correct |
471 ms |
28476 KB |
Output is correct |
4 |
Correct |
258 ms |
31504 KB |
Output is correct |
5 |
Correct |
291 ms |
27724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
452 ms |
29612 KB |
Output is correct |
2 |
Correct |
407 ms |
27740 KB |
Output is correct |
3 |
Correct |
362 ms |
26608 KB |
Output is correct |
4 |
Correct |
245 ms |
31300 KB |
Output is correct |
5 |
Correct |
276 ms |
28464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
471 ms |
29000 KB |
Output is correct |
2 |
Correct |
527 ms |
33808 KB |
Output is correct |
3 |
Correct |
488 ms |
33136 KB |
Output is correct |
4 |
Correct |
289 ms |
36396 KB |
Output is correct |
5 |
Correct |
304 ms |
31964 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
592 ms |
34500 KB |
Output is correct |
2 |
Correct |
458 ms |
32244 KB |
Output is correct |
3 |
Correct |
402 ms |
31376 KB |
Output is correct |
4 |
Correct |
303 ms |
36268 KB |
Output is correct |
5 |
Correct |
308 ms |
33088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
563 ms |
33148 KB |
Output is correct |
2 |
Correct |
571 ms |
38544 KB |
Output is correct |
3 |
Correct |
587 ms |
37864 KB |
Output is correct |
4 |
Correct |
331 ms |
41724 KB |
Output is correct |
5 |
Correct |
362 ms |
37336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
586 ms |
39408 KB |
Output is correct |
2 |
Correct |
507 ms |
36716 KB |
Output is correct |
3 |
Correct |
494 ms |
35640 KB |
Output is correct |
4 |
Correct |
333 ms |
41584 KB |
Output is correct |
5 |
Correct |
339 ms |
37780 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
706 ms |
41216 KB |
Output is correct |
2 |
Correct |
699 ms |
48164 KB |
Output is correct |
3 |
Correct |
769 ms |
47204 KB |
Output is correct |
4 |
Correct |
412 ms |
51628 KB |
Output is correct |
5 |
Correct |
460 ms |
46072 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
750 ms |
48976 KB |
Output is correct |
2 |
Correct |
650 ms |
45896 KB |
Output is correct |
3 |
Correct |
609 ms |
44768 KB |
Output is correct |
4 |
Correct |
416 ms |
51752 KB |
Output is correct |
5 |
Correct |
459 ms |
47236 KB |
Output is correct |