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 {
FastIO io = new FastIO(); num = io.nextInt(); int L = io.nextInt(); arr = new double[num][2];
for (int i = 0;i<num;i++) {
arr[i][0] = io.nextInt(); arr[i][1] = io.nextInt();
}
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);
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 [left,right] and [endpoints.get(i).l,endpoints.get(i).r] overlap, take union
double newL = endpoints.get(i).l; double newR = endpoints.get(i).r;
if (newL<=right) right = Math.max(right, newR);
if (left<=newR) left = Math.min(left, newL);
}
work = left<=0&&right>=L;
if (work) h = mid;
else l = mid;
}
io.println((l+h)/2); io.close();
}
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;
double sqrt = Math.sqrt(r*r-arr[i][1]*arr[i][1]);
if (arr[i][0]+sqrt<0) continue;
endpoints.add(new Pair(arr[i][0]-sqrt,arr[i][0]+sqrt));
}
return endpoints;
}
public static class Pair {
double l; double r;
public Pair (double l, double r) {
this.l = l; this.r = r;
}
}
public static class FastIO extends PrintWriter {
private InputStream stream;
private byte[] buf = new byte[1 << 16];
private int curChar;
private int numChars;
// standard input
public FastIO() { this(System.in, System.out); }
public FastIO(InputStream i, OutputStream o) {
super(o);
stream = i;
}
public FastIO(String i, String o) throws IOException {
super(new FileWriter(o));
stream = new FileInputStream(i);
}
// throws InputMismatchException() if previously detected end of file
private int nextByte() {
if (numChars == -1) { throw new InputMismatchException(); }
if (curChar >= numChars) {
curChar = 0;
try {
numChars = stream.read(buf);
} catch (IOException e) { throw new InputMismatchException(); }
if (numChars == -1) {
return -1; // end of file
}
}
return buf[curChar++];
}
public int nextInt() { // nextLong() would be implemented similarly
int c;
do { c = nextByte(); } while (c <= ' ');
int sgn = 1;
if (c == '-') {
sgn = -1;
c = nextByte();
}
int res = 0;
do {
if (c < '0' || c > '9') { throw new InputMismatchException(); }
res = 10 * res + c - '0';
c = nextByte();
} while (c > ' ');
return res * sgn;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
50 ms |
14072 KB |
Output is correct |
2 |
Correct |
47 ms |
14404 KB |
Output is correct |
3 |
Correct |
46 ms |
16304 KB |
Output is correct |
4 |
Correct |
58 ms |
14272 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
60 ms |
14244 KB |
Output is correct |
2 |
Correct |
50 ms |
14172 KB |
Output is correct |
3 |
Correct |
60 ms |
15876 KB |
Output is correct |
4 |
Correct |
61 ms |
14480 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
104 ms |
14308 KB |
Output is correct |
2 |
Correct |
95 ms |
12528 KB |
Output is correct |
3 |
Correct |
94 ms |
12092 KB |
Output is correct |
4 |
Correct |
96 ms |
12184 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
112 ms |
12528 KB |
Output is correct |
2 |
Correct |
91 ms |
14892 KB |
Output is correct |
3 |
Correct |
118 ms |
12648 KB |
Output is correct |
4 |
Correct |
105 ms |
14888 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
114 ms |
14688 KB |
Output is correct |
2 |
Correct |
99 ms |
12960 KB |
Output is correct |
3 |
Correct |
109 ms |
14732 KB |
Output is correct |
4 |
Correct |
111 ms |
12508 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
125 ms |
12828 KB |
Output is correct |
2 |
Correct |
95 ms |
16788 KB |
Output is correct |
3 |
Correct |
121 ms |
18736 KB |
Output is correct |
4 |
Correct |
109 ms |
18692 KB |
Output is correct |
5 |
Correct |
104 ms |
18760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
237 ms |
30388 KB |
Output is correct |
2 |
Correct |
332 ms |
30468 KB |
Output is correct |
3 |
Correct |
212 ms |
26356 KB |
Output is correct |
4 |
Correct |
195 ms |
31744 KB |
Output is correct |
5 |
Correct |
185 ms |
23476 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
254 ms |
30828 KB |
Output is correct |
2 |
Correct |
180 ms |
28896 KB |
Output is correct |
3 |
Correct |
237 ms |
31708 KB |
Output is correct |
4 |
Correct |
200 ms |
32284 KB |
Output is correct |
5 |
Correct |
210 ms |
31100 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
329 ms |
30780 KB |
Output is correct |
2 |
Correct |
351 ms |
31588 KB |
Output is correct |
3 |
Correct |
238 ms |
33148 KB |
Output is correct |
4 |
Correct |
161 ms |
27336 KB |
Output is correct |
5 |
Correct |
223 ms |
31064 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
270 ms |
36724 KB |
Output is correct |
2 |
Correct |
325 ms |
34628 KB |
Output is correct |
3 |
Correct |
251 ms |
36032 KB |
Output is correct |
4 |
Correct |
154 ms |
28916 KB |
Output is correct |
5 |
Correct |
223 ms |
32552 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
201 ms |
35408 KB |
Output is correct |
2 |
Correct |
279 ms |
34848 KB |
Output is correct |
3 |
Correct |
253 ms |
33700 KB |
Output is correct |
4 |
Correct |
152 ms |
29252 KB |
Output is correct |
5 |
Correct |
215 ms |
34172 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1038 ms |
117448 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1075 ms |
117512 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
488 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
516 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
542 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
534 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
508 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
466 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
405 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
383 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |