Submission #605828

# Submission time Handle Problem Language Result Execution time Memory
605828 2022-07-26T03:04:55 Z bzhu524 Mobile (BOI12_mobile) Java 11
95 / 100
1000 ms 68204 KB
import java.util.*;
import java.io.*;


public class mobile {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        StringTokenizer l1 = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(l1.nextToken());
        int len = Integer.parseInt(l1.nextToken());
        Point[] points = new Point[n];
        for (int i=0; i<n; i++) {
            StringTokenizer st = new StringTokenizer(br.readLine());
            long x = Long.parseLong(st.nextToken());
            long y = Long.parseLong(st.nextToken());
            points[i] = new Point(x, y);
        }

        double lower = 1;
        double upper = 1000000000;
        
        while (upper - lower > 1e-3) {
            double mid = (upper + lower) / 2;
            double currPoint = 0;
            for (int i=0; i<n; i++) { // remove this loop for faster solution
                long x = points[i].x;
                long y = points[i].y;

                double delta = Math.sqrt(mid * mid - y * y);
                double p1 = x - delta;
                double p2 = x + delta;

                if (p1 <= currPoint) {
                    currPoint = Math.max(currPoint, p2);
                }
            }
            if (currPoint < len) {
                lower = mid;
            } else {
                upper = mid;
            }
        }

        String r = String.format("%.6f", lower);
        System.out.println(r);
    }

    static class Point {
        long x;
        long y;
        public Point(long x, long y) {
            this.x = x;
            this.y = y;
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 87 ms 9264 KB Output is correct
2 Correct 80 ms 9528 KB Output is correct
3 Correct 76 ms 9164 KB Output is correct
4 Correct 74 ms 9408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 78 ms 9232 KB Output is correct
2 Correct 92 ms 9268 KB Output is correct
3 Correct 95 ms 9408 KB Output is correct
4 Correct 89 ms 9176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 184 ms 13124 KB Output is correct
2 Correct 198 ms 12860 KB Output is correct
3 Correct 147 ms 11392 KB Output is correct
4 Correct 198 ms 13084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 223 ms 13484 KB Output is correct
2 Correct 222 ms 13416 KB Output is correct
3 Correct 222 ms 13584 KB Output is correct
4 Correct 231 ms 13288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 223 ms 13360 KB Output is correct
2 Correct 229 ms 13364 KB Output is correct
3 Correct 250 ms 13348 KB Output is correct
4 Correct 263 ms 13616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 220 ms 13432 KB Output is correct
2 Correct 241 ms 13460 KB Output is correct
3 Correct 240 ms 13524 KB Output is correct
4 Correct 228 ms 13352 KB Output is correct
5 Correct 212 ms 13548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 310 ms 17148 KB Output is correct
2 Correct 328 ms 17068 KB Output is correct
3 Correct 281 ms 16304 KB Output is correct
4 Correct 315 ms 16880 KB Output is correct
5 Correct 270 ms 15972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 396 ms 17036 KB Output is correct
2 Correct 291 ms 17168 KB Output is correct
3 Correct 322 ms 17264 KB Output is correct
4 Correct 331 ms 17024 KB Output is correct
5 Correct 304 ms 17252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 359 ms 17700 KB Output is correct
2 Correct 301 ms 17220 KB Output is correct
3 Correct 317 ms 17308 KB Output is correct
4 Correct 329 ms 18052 KB Output is correct
5 Correct 368 ms 17528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 317 ms 17808 KB Output is correct
2 Correct 320 ms 18036 KB Output is correct
3 Correct 297 ms 17724 KB Output is correct
4 Correct 333 ms 18044 KB Output is correct
5 Correct 329 ms 17904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 357 ms 17972 KB Output is correct
2 Correct 320 ms 17740 KB Output is correct
3 Correct 285 ms 18116 KB Output is correct
4 Correct 319 ms 17788 KB Output is correct
5 Correct 323 ms 17960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 520 ms 37252 KB Output is correct
2 Correct 591 ms 36396 KB Output is correct
3 Correct 585 ms 36160 KB Output is correct
4 Correct 599 ms 37088 KB Output is correct
5 Correct 587 ms 36116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 581 ms 36688 KB Output is correct
2 Correct 705 ms 36368 KB Output is correct
3 Correct 540 ms 36420 KB Output is correct
4 Correct 618 ms 37276 KB Output is correct
5 Correct 570 ms 36116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 589 ms 45660 KB Output is correct
2 Correct 673 ms 45844 KB Output is correct
3 Correct 652 ms 45952 KB Output is correct
4 Correct 662 ms 45096 KB Output is correct
5 Correct 633 ms 45920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 648 ms 45172 KB Output is correct
2 Correct 753 ms 46132 KB Output is correct
3 Correct 591 ms 44304 KB Output is correct
4 Correct 679 ms 45556 KB Output is correct
5 Correct 694 ms 45912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 658 ms 49436 KB Output is correct
2 Correct 676 ms 48932 KB Output is correct
3 Correct 705 ms 49104 KB Output is correct
4 Correct 733 ms 49984 KB Output is correct
5 Correct 673 ms 49020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 632 ms 49732 KB Output is correct
2 Correct 808 ms 49172 KB Output is correct
3 Correct 656 ms 48924 KB Output is correct
4 Correct 680 ms 48620 KB Output is correct
5 Correct 732 ms 49304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 673 ms 53496 KB Output is correct
2 Correct 677 ms 52652 KB Output is correct
3 Correct 678 ms 52716 KB Output is correct
4 Correct 703 ms 52572 KB Output is correct
5 Correct 716 ms 52536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 656 ms 52612 KB Output is correct
2 Correct 837 ms 52736 KB Output is correct
3 Correct 661 ms 52508 KB Output is correct
4 Correct 710 ms 53004 KB Output is correct
5 Correct 730 ms 52696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 841 ms 65292 KB Output is correct
2 Correct 832 ms 67340 KB Output is correct
3 Correct 837 ms 67340 KB Output is correct
4 Correct 865 ms 66700 KB Output is correct
5 Correct 895 ms 67308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 835 ms 68204 KB Output is correct
2 Execution timed out 1029 ms 67440 KB Time limit exceeded
3 Halted 0 ms 0 KB -