Submission #1102805

#TimeUsernameProblemLanguageResultExecution timeMemory
1102805uranium235Mobile (BOI12_mobile)Java
0 / 100
1072 ms131072 KiB
//package ojuz; import java.io.*; import java.util.*; import java.util.function.DoublePredicate; public class mobile { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String[] first = reader.readLine().split(" "); int n = Integer.parseInt(first[0]), l = Integer.parseInt(first[1]); Range[] ranges = new Range[n]; for (int i = 0; i < n; i++) { first = reader.readLine().split(" "); ranges[i] = new Range(Integer.parseInt(first[0]), Integer.parseInt(first[1])); } double radius = firstTrue(1e-9, 1e10, d -> { // System.out.println("testing " + d); Queue<Double> queue = new PriorityQueue<>((a, b) -> { if (Math.abs(a) != Math.abs(b)) return Double.compare(Math.abs(a), Math.abs(b)); return Double.compare(b, a); }); for (Range r : ranges) { double left = r.x - Math.sqrt(d * d - r.y * r.y); if (Double.isNaN(left)) continue; queue.add(Math.max(left, 0)); queue.add(-Math.min(r.x + r.x - left, l)); // System.out.println("added " + (r.x + r.x - left)); } int in = 0; while (!queue.isEmpty()) { double val = queue.poll(); if (val == -l) return true; // System.out.println("val " + val); if (val < 0) { in--; if (in == 0) return false; } else in++; } return true; }); System.out.println(radius); } public static double firstTrue(double lo, double hi, DoublePredicate pred) { hi += Math.ulp(hi); double prevMid = -1; while (lo < hi) { double mid = lo + (hi - lo) / 2; if (Math.abs(mid - prevMid) < 1e-6) return lo; if (pred.test(mid)) hi = mid; else lo = mid + Math.ulp(mid); prevMid = mid; } return lo; } static class Range { public final int x, y; public double left, right; public Range(int x, int y) { this.x = x; this.y = y; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...