Submission #1066725

# Submission time Handle Problem Language Result Execution time Memory
1066725 2024-08-20T05:50:50 Z Oz121 Mobile (BOI12_mobile) Java 11
4 / 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("--------");*/

            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;
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 58 ms 10948 KB Output is correct
2 Runtime error 65 ms 9548 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 81 ms 10648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 244 ms 15724 KB Output is correct
2 Runtime error 182 ms 15264 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 310 ms 15648 KB Output is correct
2 Correct 226 ms 15100 KB Output is correct
3 Correct 321 ms 16424 KB Output is correct
4 Correct 264 ms 15868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 290 ms 16204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 223 ms 15208 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 461 ms 26612 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 666 ms 27924 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 520 ms 28116 KB Output is correct
2 Correct 955 ms 30472 KB Output is correct
3 Correct 545 ms 29800 KB Output is correct
4 Incorrect 576 ms 31332 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 735 ms 29648 KB Output is correct
2 Correct 982 ms 35720 KB Output is correct
3 Correct 916 ms 33188 KB Output is correct
4 Correct 486 ms 31216 KB Output is correct
5 Incorrect 713 ms 32972 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 725 ms 29188 KB Output is correct
2 Execution timed out 1025 ms 34352 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1073 ms 109556 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 103204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1066 ms 128364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1036 ms 96540 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 590 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1052 ms 106932 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 768 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 992 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 649 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 903 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -