이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//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 = 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(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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |