답안 #1066728

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1066728 2024-08-20T05:52:57 Z Oz121 Mobile (BOI12_mobile) Java 11
13 / 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;
            ArrayList<Pair> endpoints = getEndpoints(mid);
            endpoints.sort(Comparator.comparingDouble(i -> i.l));

            /*System.out.println("  "+mid);
            for (int i = 0;i<endpoints.size();i++) {
                System.out.println(endpoints.get(i).l+" "+endpoints.get(i).r);
            }
            System.out.println("--------");*/

            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 (endpoints.get(i).l>right) work = false;
                left = Math.min(left, endpoints.get(i).l); right = Math.max(right, endpoints.get(i).r);
            }
            work = (work)&&(left<=0&&right>=L);

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

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

    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;
            endpoints.add(new Pair(arr[i][0]-Math.sqrt(r*r-arr[i][1]*arr[i][1]),
                            arr[i][0]+Math.sqrt(r*r-arr[i][1]*arr[i][1])));
        }
        return endpoints;
    }

    public static class Pair {
        double l; double r;
        public Pair (double l, double r) {
            this.l = l; this.r = r;
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 11056 KB Output is correct
2 Correct 71 ms 10732 KB Output is correct
3 Correct 60 ms 9772 KB Output is correct
4 Correct 66 ms 9224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 91 ms 10440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 260 ms 15692 KB Output is correct
2 Correct 195 ms 14584 KB Output is correct
3 Incorrect 218 ms 15024 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 316 ms 15708 KB Output is correct
2 Correct 215 ms 15072 KB Output is correct
3 Correct 326 ms 16432 KB Output is correct
4 Correct 270 ms 16136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 310 ms 15780 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 283 ms 14728 KB Output is correct
2 Correct 205 ms 15204 KB Output is correct
3 Correct 424 ms 16532 KB Output is correct
4 Correct 259 ms 15940 KB Output is correct
5 Correct 318 ms 16492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 510 ms 27108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 670 ms 28128 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 522 ms 27928 KB Output is correct
2 Correct 957 ms 30696 KB Output is correct
3 Correct 503 ms 28664 KB Output is correct
4 Incorrect 581 ms 29344 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 719 ms 29804 KB Output is correct
2 Correct 957 ms 34340 KB Output is correct
3 Correct 937 ms 32252 KB Output is correct
4 Correct 521 ms 31004 KB Output is correct
5 Incorrect 738 ms 31568 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 709 ms 29236 KB Output is correct
2 Execution timed out 1034 ms 34272 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1067 ms 109480 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1018 ms 103312 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1030 ms 122992 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1057 ms 107680 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 634 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1018 ms 107196 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 805 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1014 ms 131072 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 646 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 963 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -