#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
double k;
int n; cin >> n >> k;
vector<pair<double,double>> v(n);
for(auto &x : v)cin >> x.first >> x.second;
double l = 0, r = 2e9;
while((r-l) > 0.001){
double mid = (l+r)/2.0;
vector<double> ran1, ran2;
for(int i = 0; i < n; ++i){
if(abs(v[i].second) >= mid)continue;
double z = sqrt(mid*mid-v[i].second*v[i].second);
while(ran1.size() && max(v[i].first-z,0.0) < ran1.back()){
ran1.pop_back();
ran2.pop_back();
}
if(ran1.empty() || v[i].first+z > ran2.back()){
if(ran1.size() && v[i].first-z < ran2.back()){
ran1.back() = max(0.0,min(v[i].first-z,ran1.back()));
ran2.back() = min(v[i].first+z,k);
}
else{
ran1.push_back(max(min(v[i].first-z,k),0.0));
ran2.push_back(min(max(v[i].first+z,0.0),k));
}
}
if(ran1.back() == ran2.back()){
ran1.pop_back();
ran2.pop_back();
}
}
if(ran1.empty() || ran1[0] != 0 || ran2.back() != k){
l = mid;
continue;
}
bool ok = 1;
for(int i = 1; i < (int)ran1.size(); ++i){
if(ran2[i-1] < ran1[i]){
ok = 0;
break;
}
if(ran2[i] == k)break;
}
if(ok){
r = mid;
}
else{
l = mid;
}
}
printf("%.3f\n", l);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
316 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 |
Incorrect |
1 ms |
316 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
372 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
3 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
332 KB |
Output is correct |
2 |
Correct |
5 ms |
460 KB |
Output is correct |
3 |
Correct |
4 ms |
324 KB |
Output is correct |
4 |
Correct |
5 ms |
460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
316 KB |
Output is correct |
2 |
Correct |
4 ms |
436 KB |
Output is correct |
3 |
Correct |
4 ms |
332 KB |
Output is correct |
4 |
Correct |
5 ms |
460 KB |
Output is correct |
5 |
Correct |
4 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
68 ms |
2220 KB |
Output is correct |
2 |
Correct |
58 ms |
2644 KB |
Output is correct |
3 |
Correct |
34 ms |
1764 KB |
Output is correct |
4 |
Correct |
49 ms |
2620 KB |
Output is correct |
5 |
Correct |
28 ms |
1468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
49 ms |
2284 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
62 ms |
2364 KB |
Output is correct |
2 |
Correct |
79 ms |
2728 KB |
Output is correct |
3 |
Correct |
58 ms |
2592 KB |
Output is correct |
4 |
Correct |
63 ms |
3772 KB |
Output is correct |
5 |
Correct |
50 ms |
2620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
95 ms |
3420 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
84 ms |
3384 KB |
Output is correct |
2 |
Correct |
75 ms |
3268 KB |
Output is correct |
3 |
Incorrect |
64 ms |
2900 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
345 ms |
12344 KB |
Output is correct |
2 |
Correct |
403 ms |
15932 KB |
Output is correct |
3 |
Correct |
392 ms |
15300 KB |
Output is correct |
4 |
Incorrect |
323 ms |
17712 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
437 ms |
16332 KB |
Output is correct |
2 |
Correct |
389 ms |
14780 KB |
Output is correct |
3 |
Correct |
310 ms |
13880 KB |
Output is correct |
4 |
Correct |
332 ms |
17476 KB |
Output is correct |
5 |
Correct |
318 ms |
15428 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
417 ms |
14868 KB |
Output is correct |
2 |
Correct |
487 ms |
18984 KB |
Output is correct |
3 |
Correct |
460 ms |
18400 KB |
Output is correct |
4 |
Correct |
393 ms |
21600 KB |
Output is correct |
5 |
Correct |
366 ms |
17692 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
488 ms |
19552 KB |
Output is correct |
2 |
Correct |
477 ms |
17624 KB |
Output is correct |
3 |
Correct |
364 ms |
16452 KB |
Output is correct |
4 |
Correct |
409 ms |
21352 KB |
Output is correct |
5 |
Correct |
368 ms |
18424 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
512 ms |
17396 KB |
Output is correct |
2 |
Correct |
561 ms |
22004 KB |
Output is correct |
3 |
Correct |
562 ms |
21384 KB |
Output is correct |
4 |
Incorrect |
470 ms |
24708 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
552 ms |
22900 KB |
Output is correct |
2 |
Incorrect |
537 ms |
20472 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
558 ms |
19756 KB |
Output is correct |
2 |
Incorrect |
643 ms |
25384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
619 ms |
26004 KB |
Output is correct |
2 |
Correct |
604 ms |
23412 KB |
Output is correct |
3 |
Correct |
549 ms |
22296 KB |
Output is correct |
4 |
Correct |
527 ms |
28208 KB |
Output is correct |
5 |
Correct |
493 ms |
24352 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
685 ms |
24648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
754 ms |
32464 KB |
Output is correct |
2 |
Correct |
791 ms |
29148 KB |
Output is correct |
3 |
Correct |
674 ms |
28256 KB |
Output is correct |
4 |
Correct |
650 ms |
35292 KB |
Output is correct |
5 |
Correct |
594 ms |
30764 KB |
Output is correct |