# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
604455 | bzhu524 | Mobile (BOI12_mobile) | Java | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
import java.util.*;
import java.io.*;
public class Mobile {
public static void main(String[] args) {
FastIO io = new FastIO();
int n = io.nextInt();
int len = io.nextInt();
long[][] points = new long[n][n];
for (int i=0; i<n; i++) {
long x = io.nextLong();
long y = io.nextLong();
points[i][0] = x;
points[i][1] = y;
}
double lower = 1;
double upper = 10e9;
double res = Double.MAX_VALUE;
while (upper - lower >= 10e-4) {
double mid = (upper + lower) / 2;
double currPoint = 0;
for (int i=0; i<n; i++) {
long x = points[i][0];
long y = points[i][1];
double delta = Math.sqrt(mid * mid - y * y);
double dist1 = x - delta;
double dist2 = x + delta;
if (dist1 <= currPoint) {
currPoint = Math.max(currPoint, dist2);
}
}
if (currPoint < len) {
lower = mid;
} else {
upper = mid;
res = Math.min(res, mid);
}
}
String r = String.format("%.6f", res);
System.out.println(r);
}
static class FastIO extends PrintWriter {
private InputStream stream;
private byte[] buf = new byte[1<<16];
private int curChar, numChars;
// standard input
public FastIO() { this(System.in,System.out); }
public FastIO(InputStream i, OutputStream o) {
super(o);
stream = i;
}
// file input
public FastIO(String i, String o) throws IOException {
super(new FileWriter(o));
stream = new FileInputStream(i);
}
// throws InputMismatchException() if previously detected end of file
private int nextByte() {
if (numChars == -1) throw new InputMismatchException();
if (curChar >= numChars) {
curChar = 0;
try {
numChars = stream.read(buf);
} catch (IOException e) {
throw new InputMismatchException();
}
if (numChars == -1) return -1; // end of file
}
return buf[curChar++];
}
// to read in entire lines, replace c <= ' '
// with a function that checks whether c is a line break
public String next() {
int c; do { c = nextByte(); } while (c <= ' ');
StringBuilder res = new StringBuilder();
do { res.appendCodePoint(c); c = nextByte(); } while (c > ' ');
return res.toString();
}
public int nextInt() { // nextLong() would be implemented similarly
int c; do { c = nextByte(); } while (c <= ' ');
int sgn = 1; if (c == '-') { sgn = -1; c = nextByte(); }
int res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res = 10*res+c-'0';
c = nextByte();
} while (c > ' ');
return res * sgn;
}
public double nextDouble() { return Double.parseDouble(next()); }
public long nextLong() {
return Long.parseLong(next());
}
}
}