import java.io.*;
import java.util.*;
public class mobile {
public static int num; public static double[][] arr;
public static void main(String[] args) throws IOException {
BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer l1 = new StringTokenizer(scan.readLine()); num = Integer.parseInt(l1.nextToken()); int L = Integer.parseInt(l1.nextToken()); arr = new double[num][2];
for (int i = 0;i<num;i++) {
StringTokenizer st = new StringTokenizer(scan.readLine());
arr[i][0] = Integer.parseInt(st.nextToken());
arr[i][1] = Integer.parseInt(st.nextToken());
}
double l = 0; double h = Math.pow(10,9);
while (h-l>Math.pow(10,-3)) {
double mid = (l+h)/2; boolean work = true;
ArrayList<Pair> endpoints = getEndpoints(mid);
endpoints.sort(Comparator.comparingDouble(i -> i.l));
/*System.out.println(" "+mid);
for (int i = 0;i<endpoints.size();i++) {
System.out.println(endpoints.get(i).l+" "+endpoints.get(i).r);
}
System.out.println("--------");*/
if (endpoints.isEmpty()) {l = mid; continue;}
double left = endpoints.get(0).l; double right = endpoints.get(0).r;
for (int i = 1;i<endpoints.size();i++) {
if (endpoints.get(i).l>right) work = false;
left = Math.min(left, endpoints.get(i).l); right = Math.max(right, endpoints.get(i).r);
}
work = (work)&&(left<=0&&right>=L);
if (work) h = mid;
else l = mid;
}
System.out.println((l+h)/2);
}
public static ArrayList<Pair> getEndpoints (double r) {
ArrayList<Pair> endpoints = new ArrayList<>();
for (int i = 0;i<num;i++) {
if (r*r-arr[i][1]*arr[i][1]<0) continue;
endpoints.add(new Pair(arr[i][0]-Math.sqrt(r*r-arr[i][1]*arr[i][1]),
arr[i][0]+Math.sqrt(r*r-arr[i][1]*arr[i][1])));
}
return endpoints;
}
public static class Pair {
double l; double r;
public Pair (double l, double r) {
this.l = l; this.r = r;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
57 ms |
9608 KB |
Output is correct |
2 |
Correct |
56 ms |
10416 KB |
Output is correct |
3 |
Correct |
56 ms |
9464 KB |
Output is correct |
4 |
Correct |
56 ms |
9904 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
83 ms |
10260 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
267 ms |
15580 KB |
Output is correct |
2 |
Correct |
196 ms |
14756 KB |
Output is correct |
3 |
Incorrect |
215 ms |
14960 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
303 ms |
15700 KB |
Output is correct |
2 |
Correct |
211 ms |
15164 KB |
Output is correct |
3 |
Correct |
312 ms |
16208 KB |
Output is correct |
4 |
Correct |
291 ms |
15736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
305 ms |
17940 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
301 ms |
15332 KB |
Output is correct |
2 |
Correct |
244 ms |
15192 KB |
Output is correct |
3 |
Correct |
449 ms |
16276 KB |
Output is correct |
4 |
Correct |
276 ms |
15876 KB |
Output is correct |
5 |
Correct |
348 ms |
16140 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
540 ms |
26940 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
735 ms |
27792 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
612 ms |
28072 KB |
Output is correct |
2 |
Correct |
977 ms |
30692 KB |
Output is correct |
3 |
Correct |
507 ms |
29008 KB |
Output is correct |
4 |
Incorrect |
581 ms |
29632 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
724 ms |
29688 KB |
Output is correct |
2 |
Execution timed out |
1012 ms |
34424 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
701 ms |
29284 KB |
Output is correct |
2 |
Execution timed out |
1044 ms |
34276 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1050 ms |
109784 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1044 ms |
103184 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1040 ms |
122948 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1018 ms |
107760 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
575 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1025 ms |
107508 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
707 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
981 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
582 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
910 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |