제출 #682721

#제출 시각아이디문제언어결과실행 시간메모리
682721bruhgamerMobile (BOI12_mobile)Java
50 / 100
1102 ms70572 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.0001 >= 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.pow(((dis*dis) - (arr[i][1] * arr[i][1])), 0.5); //System.out.println(disx); double disxstart = arr[i][0] - disx; double disxend = arr[i][0] + disx; if(disxstart <= to) { to = Double.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(1.0, 500000000.0))); 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...