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));
}
}
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 intercepts.size() == 0;
}
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 |
63 ms |
8452 KB |
Output is correct |
2 |
Correct |
63 ms |
8552 KB |
Output is correct |
3 |
Correct |
67 ms |
8420 KB |
Output is correct |
4 |
Correct |
68 ms |
8448 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
106 ms |
11172 KB |
Output is correct |
2 |
Correct |
113 ms |
11184 KB |
Output is correct |
3 |
Correct |
121 ms |
11576 KB |
Output is correct |
4 |
Correct |
128 ms |
11516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
398 ms |
14744 KB |
Output is correct |
2 |
Correct |
552 ms |
15432 KB |
Output is correct |
3 |
Correct |
390 ms |
14844 KB |
Output is correct |
4 |
Correct |
546 ms |
15576 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
527 ms |
15124 KB |
Output is correct |
2 |
Correct |
449 ms |
14904 KB |
Output is correct |
3 |
Correct |
760 ms |
15676 KB |
Output is correct |
4 |
Incorrect |
551 ms |
15564 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
595 ms |
15192 KB |
Output is correct |
2 |
Correct |
445 ms |
14800 KB |
Output is correct |
3 |
Correct |
683 ms |
15560 KB |
Output is correct |
4 |
Incorrect |
656 ms |
15668 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
668 ms |
15132 KB |
Output is correct |
2 |
Correct |
434 ms |
14824 KB |
Output is correct |
3 |
Correct |
784 ms |
15744 KB |
Output is correct |
4 |
Incorrect |
614 ms |
15128 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1077 ms |
31952 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1067 ms |
32192 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1070 ms |
27288 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1064 ms |
29008 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1055 ms |
36304 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1067 ms |
86152 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1071 ms |
77932 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1060 ms |
99140 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1069 ms |
84088 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1064 ms |
102220 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1085 ms |
101720 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
968 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1018 ms |
91680 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1044 ms |
131072 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1074 ms |
119224 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |