Submission #1129916

#TimeUsernameProblemLanguageResultExecution timeMemory
1129916APersonMobile (BOI12_mobile)Java
Compilation error
0 ms0 KiB
import java.util.*; public class Mobile { static int n, l; static Point[] p; public static void main(String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); l = sc.nextInt(); p = new Point[n]; for(int i = 0; i < n; i++) p[i] = new Point(sc.nextDouble(), sc.nextDouble()); double min = 0; double max = 1e10; while(max-min > 1e-3) { double mid = (max+min)/2; if(works(mid)) min = mid; else max = mid; } System.out.println(min); sc.close(); } public static boolean works(double x) { Interval[] intervals = new Interval[n]; for(int i = 0; i < n; i++) { double xDist = Math.sqrt(x*x-p[i].y*p[i].y); intervals[i] = new Interval(p[i].x-xDist, p[i].x+xDist); } Arrays.sort(intervals, Comparator.comparing(a -> a.l)); double last = 0; for(int i = 0; i < n; i++) { if(last >= l) return false; if(intervals[i].l > last) return true; last = Math.max(last, intervals[i].r); } return last < l; } public static class Interval { double l, r; public Interval(double l, double r) { this.l = l; this.r = r; } } public static class Point { double x, y; public Point(double x, double y) { this.x = x; this.y = Math.abs(y); } } }

Compilation message (stderr)

mobile.java:2: error: class Mobile is public, should be declared in a file named Mobile.java
public class Mobile {
       ^
1 error

=======