Submission #682706

#TimeUsernameProblemLanguageResultExecution timeMemory
682706bruhgamerMobile (BOI12_mobile)Java
0 / 100
905 ms86152 KiB
//package USACO; import java.util.*; import java.io.*; public class mobile { public static long search(long start, long end) { if(start == end) { return start; } long mid = (start + end - 1)/2; if(works(mid)) { return search(start, mid); } return search(mid+1,end); } public static int n; public static int l; public static long[][]arr; public static boolean works(long dis) { long to = 0; for(int i = 0; i < n; i++) { long disx = (long) Math.sqrt(dis - (arr[i][1] * arr[i][1])); long disxstart = arr[i][0] - disx; long disxend = arr[i][0] + disx; if(disxstart > (to+1)) { return false; } to = Math.max(disxend, 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(); } long val = search(0L, Long.MAX_VALUE); //io.println(val); io.println(Math.sqrt(val)); 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...