import java.io.*;
import java.util.*;
public class mobile {
static int N;
static int L;
static int[][] coordinates;
public static void main(String[] args) throws IOException {
BufferedReader br;
PrintWriter out;
StringTokenizer st;
try {
br = new BufferedReader(new FileReader("highcard.in"));
out = new PrintWriter(new BufferedWriter(new FileWriter("highcard.out")));
st = new StringTokenizer(br.readLine());
} catch (Exception e) {
br = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(System.out);
st = new StringTokenizer(br.readLine());
}
N = Integer.parseInt(st.nextToken());
L = Integer.parseInt(st.nextToken());
coordinates = new int[N][2];
for(int i = 0; i < N; i++) {
st = new StringTokenizer(br.readLine());
coordinates[i][0] = Integer.parseInt(st.nextToken());
coordinates[i][1] = Integer.parseInt(st.nextToken());
}
double left = 0;
double right = 1500000000;
double answer = 0;
do {
double mid = (left + right) / 2;
boolean working = works(mid);
if (working) {
answer = mid;
left = mid;
} else {
right = mid;
}
} while (Math.abs(left - right) > 0.00001);
out.print(answer);
out.close();
}
static boolean works(double radius) {
ArrayList<Intercept> intercepts = new ArrayList<>();
for(int[] c : coordinates) {
int h = c[0];
int k = c[1];
double discriminant = radius * radius - k * k;
if(discriminant > 0) {
double sqrt = Math.sqrt(discriminant);
intercepts.add(new Intercept(sqrt + h, 1));
intercepts.add(new Intercept(-sqrt + h, 2));
} else if (discriminant == 0) {
intercepts.add(new Intercept(h, 0));
}
}
if(intercepts.size() == 0) {
return true;
}
intercepts.sort(new Compare());
int numCircles = 0;
for (Intercept intercept : intercepts) {
if (intercept.x >= 0 && intercept.x <= L) {
if(numCircles == 0 || (numCircles == 1 && intercept.type == 2)) {
return true;
}
}
if (intercept.type == 1) {
numCircles++;
} else if (intercept.type == 2) {
numCircles--;
}
}
return false;
}
static class Intercept {
double x;
int type;
public Intercept(double x, int t) {
this.x = x;
type = t;
}
}
static class Compare implements Comparator<Intercept> {
@Override
public int compare(Intercept o1, Intercept o2) {
if(o1.x < o2.x) {
return -1;
} else if (o1.x == o2.x) {
return 0;
}
return 1;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
74 ms |
8612 KB |
Output is correct |
2 |
Correct |
66 ms |
8564 KB |
Output is correct |
3 |
Correct |
67 ms |
8672 KB |
Output is correct |
4 |
Correct |
70 ms |
8560 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
112 ms |
11260 KB |
Output is correct |
2 |
Correct |
108 ms |
11184 KB |
Output is correct |
3 |
Correct |
125 ms |
11496 KB |
Output is correct |
4 |
Correct |
147 ms |
11704 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
391 ms |
14748 KB |
Output is correct |
2 |
Incorrect |
558 ms |
15296 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
526 ms |
15076 KB |
Output is correct |
2 |
Correct |
438 ms |
15080 KB |
Output is correct |
3 |
Correct |
705 ms |
15620 KB |
Output is correct |
4 |
Incorrect |
552 ms |
15792 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
574 ms |
15072 KB |
Output is correct |
2 |
Correct |
424 ms |
15248 KB |
Output is correct |
3 |
Correct |
646 ms |
15508 KB |
Output is correct |
4 |
Incorrect |
598 ms |
15588 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
603 ms |
15208 KB |
Output is correct |
2 |
Correct |
438 ms |
15172 KB |
Output is correct |
3 |
Correct |
748 ms |
15576 KB |
Output is correct |
4 |
Incorrect |
641 ms |
15596 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1060 ms |
32560 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1075 ms |
32340 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1066 ms |
27864 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1074 ms |
29056 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1070 ms |
38484 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1072 ms |
86396 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1068 ms |
78060 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1057 ms |
99140 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1066 ms |
84224 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1079 ms |
102360 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1080 ms |
101668 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
926 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1066 ms |
91940 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1004 ms |
131072 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1074 ms |
119456 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |