답안 #1066719

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1066719 2024-08-20T05:41:53 Z Oz121 Mobile (BOI12_mobile) Java 11
0 / 100
1000 ms 131072 KB
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;
            double[][] endpoints = getEndpoints(mid);

            Arrays.sort(endpoints, (i,j)->Double.compare(i[0],j[0]));

            /*System.out.println("  "+mid);
            for (int i = 0;i<num;i++) {
                System.out.println(endpoints[i][0]+" "+endpoints[i][1]);
            }
            System.out.println("--------");*/

            double left = endpoints[0][0]; double right = endpoints[0][1];
            for (int i = 1;i<num;i++) {
                if (endpoints[i][0]>right) work = false;
                left = Math.min(left, endpoints[i][0]); right = Math.max(right, endpoints[i][1]);
            }
            work = (work)&&(left<=0&&right>=L);

            if (work) h = mid;
            else l = mid;
        }

        System.out.println((l+h)/2);
    }

    public static double[][] getEndpoints (double r) {
        double[][] endpoints = new double[num][2];
        for (int i = 0;i<num;i++) {
            endpoints[i][0] = arr[i][0]-Math.sqrt(r*r-arr[i][1]*arr[i][1]);
            endpoints[i][1] = arr[i][0]+Math.sqrt(r*r-arr[i][1]*arr[i][1]);
        }
        return endpoints;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 51 ms 11320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 109 ms 12340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 651 ms 19900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 670 ms 17384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 810 ms 18108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 317 ms 15256 KB Output is correct
2 Correct 193 ms 15132 KB Output is correct
3 Incorrect 826 ms 17780 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1043 ms 28692 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1046 ms 29440 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 511 ms 27848 KB Output is correct
2 Execution timed out 1032 ms 28696 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1027 ms 35656 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 740 ms 34432 KB Output is correct
2 Execution timed out 1041 ms 31808 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1020 ms 102308 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1028 ms 60056 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1016 ms 131072 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1033 ms 66724 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 903 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1062 ms 75760 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 650 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1060 ms 85896 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 625 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1037 ms 120808 KB Time limit exceeded
2 Halted 0 ms 0 KB -