# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
309258 | TruaShamu | Mobile (BOI12_mobile) | Java | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class BOI12 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
ArrayList<Point> pList = new ArrayList<>();
int N = Integer.parseInt(st.nextToken());
int M = Integer.parseInt(st.nextToken());
//Read in points
for (int i = 0; i < N; i++) {
st = new StringTokenizer(br.readLine());
int x = Integer.parseInt(st.nextToken());
int y = Integer.parseInt(st.nextToken());
pList.add(new Point(x, y));
}
double left = 1, right = 5e8;
while (right - left > 1e-3) {
double mid = (left + right) / 2;
double curr = 0;
for (int i = 0; i < N; i++) {
double delta = Math.pow(mid * mid - pList.get(i).y * pList.get(i).y, 1 / 2); //(sqrt)
double a = pList.get(i).x - delta;
double b = pList.get(i).x + delta;
if (a <= curr) {
curr = Double.max(curr, b);
}
}
if (curr >= M) {
right = mid;
} else {
left = mid;
}
}
}
}