Submission #682713

#TimeUsernameProblemLanguageResultExecution timeMemory
682713bruhgamerMobile (BOI12_mobile)Java
0 / 100
1090 ms70544 KiB
//package USACO; import java.util.*; import java.io.*; import java.text.DecimalFormat; public class mobile { public static double search(double start, double end) { //System.out.println(start + " " + end); if(start + 0.001 >= end) { return start; } double mid = (start + end)/2; if(works(mid)) { return search(start, mid); } return search(mid, end); } public static int n; public static int l; public static long[][]arr; public static boolean works(double dis) { double to = 0.0; for(int i = 0; i < n; i++) { double disx = Math.sqrt((dis*dis) - (arr[i][1] * arr[i][1])); //System.out.println(disx); double disxstart = arr[i][0] - disx; double disxend = arr[i][0] + disx; if(disxstart > to) { return false; } to = Math.max(disxend, to); //System.out.println(dis + " " + to); } return to >= l; } public static void main(String[]args) throws IOException{ Kattio io = new Kattio(); n = io.nextInt(); l = io.nextInt(); arr = new long[n][2]; for(int i = 0; i < n; i++) { arr[i][0] = io.nextLong(); arr[i][1] = io.nextLong(); } DecimalFormat df = new DecimalFormat("#.#######"); io.println(df.format(search(0.0, Double.MAX_VALUE))); io.close(); } static class Kattio extends PrintWriter { private BufferedReader r; private StringTokenizer st; // standard input public Kattio() { this(System.in, System.out); } public Kattio(InputStream i, OutputStream o) { super(o); r = new BufferedReader(new InputStreamReader(i)); } // USACO-style file input public Kattio(String problemName) throws IOException { super(problemName + ".out"); r = new BufferedReader(new FileReader(problemName + ".in")); } // returns null if no more input public String next() { try { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(r.readLine()); return st.nextToken(); } catch (Exception e) { } return null; } public int nextInt() { return Integer.parseInt(next()); } public double nextDouble() { return Double.parseDouble(next()); } public long nextLong() { return Long.parseLong(next()); } } }
#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...