# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1067973 |
2024-08-21T06:17:21 Z |
Oz121 |
Mobile (BOI12_mobile) |
Java 11 |
|
1000 ms |
131072 KB |
import java.io.*;
import java.util.*;
public class mobile {
public static int num; public static double[][] arr;
public static void main(String[] args) throws IOException {
FastIO io = new FastIO(); num = io.nextInt(); int L = io.nextInt(); arr = new double[num][2];
for (int i = 0;i<num;i++) {
arr[i][0] = io.nextInt(); arr[i][1] = io.nextInt();
}
double l = 0; double h = 2*Math.pow(10,9);
while (h-l>Math.pow(10,-3)) {
double mid = (l+h)/2; boolean work = true;
ArrayList<Pair> endpoints = getEndpoints(mid);
if (endpoints.isEmpty()) {l = mid; continue;}
double left = endpoints.get(0).l; double right = endpoints.get(0).r;
for (int i = 1;i<endpoints.size();i++) { //If [left,right] and [endpoints.get(i).l,endpoints.get(i).r] overlap, take union
double newL = endpoints.get(i).l; double newR = endpoints.get(i).r;
if (newL<=right) right = Math.max(right, newR);
if (left<=newR) left = Math.min(left, newL);
}
work = left<=0&&right>=L;
if (work) h = mid;
else l = mid;
}
io.println((l+h)/2); io.close();
}
public static ArrayList<Pair> getEndpoints (double r) {
ArrayList<Pair> endpoints = new ArrayList<>();
for (int i = 0;i<num;i++) {
if (r*r-arr[i][1]*arr[i][1]<0) continue;
double sqrt = Math.sqrt(r*r-arr[i][1]*arr[i][1]);
if (arr[i][0]+sqrt<0) continue;
endpoints.add(new Pair(arr[i][0]-sqrt,arr[i][0]+sqrt));
}
return endpoints;
}
public static class Pair {
double l; double r;
public Pair (double l, double r) {
this.l = l; this.r = r;
}
}
public static class FastIO extends PrintWriter {
private InputStream stream;
private byte[] buf = new byte[1 << 16];
private int curChar;
private int numChars;
// standard input
public FastIO() { this(System.in, System.out); }
public FastIO(InputStream i, OutputStream o) {
super(o);
stream = i;
}
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++];
}
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;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
14568 KB |
Output is correct |
2 |
Correct |
55 ms |
15712 KB |
Output is correct |
3 |
Correct |
45 ms |
14508 KB |
Output is correct |
4 |
Correct |
63 ms |
16148 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
16324 KB |
Output is correct |
2 |
Correct |
58 ms |
14392 KB |
Output is correct |
3 |
Correct |
59 ms |
16052 KB |
Output is correct |
4 |
Correct |
55 ms |
14136 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
96 ms |
18048 KB |
Output is correct |
2 |
Correct |
98 ms |
18740 KB |
Output is correct |
3 |
Correct |
91 ms |
18420 KB |
Output is correct |
4 |
Correct |
89 ms |
18192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
114 ms |
17068 KB |
Output is correct |
2 |
Correct |
90 ms |
18704 KB |
Output is correct |
3 |
Correct |
104 ms |
18944 KB |
Output is correct |
4 |
Correct |
102 ms |
17024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
120 ms |
16552 KB |
Output is correct |
2 |
Correct |
86 ms |
18960 KB |
Output is correct |
3 |
Correct |
108 ms |
16368 KB |
Output is correct |
4 |
Correct |
111 ms |
18644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
127 ms |
18844 KB |
Output is correct |
2 |
Correct |
88 ms |
16752 KB |
Output is correct |
3 |
Correct |
107 ms |
16960 KB |
Output is correct |
4 |
Correct |
128 ms |
16336 KB |
Output is correct |
5 |
Correct |
104 ms |
16564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
251 ms |
30488 KB |
Output is correct |
2 |
Correct |
369 ms |
29304 KB |
Output is correct |
3 |
Correct |
222 ms |
23476 KB |
Output is correct |
4 |
Correct |
215 ms |
30496 KB |
Output is correct |
5 |
Correct |
189 ms |
23068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
270 ms |
29304 KB |
Output is correct |
2 |
Correct |
191 ms |
27716 KB |
Output is correct |
3 |
Correct |
246 ms |
29360 KB |
Output is correct |
4 |
Correct |
207 ms |
30904 KB |
Output is correct |
5 |
Correct |
216 ms |
31568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
353 ms |
30724 KB |
Output is correct |
2 |
Correct |
401 ms |
31680 KB |
Output is correct |
3 |
Correct |
261 ms |
31524 KB |
Output is correct |
4 |
Correct |
186 ms |
28992 KB |
Output is correct |
5 |
Correct |
219 ms |
30584 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
285 ms |
34792 KB |
Output is correct |
2 |
Correct |
295 ms |
36880 KB |
Output is correct |
3 |
Correct |
271 ms |
34608 KB |
Output is correct |
4 |
Correct |
182 ms |
28936 KB |
Output is correct |
5 |
Correct |
221 ms |
32464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
219 ms |
35504 KB |
Output is correct |
2 |
Correct |
286 ms |
34896 KB |
Output is correct |
3 |
Correct |
285 ms |
36884 KB |
Output is correct |
4 |
Correct |
195 ms |
32540 KB |
Output is correct |
5 |
Correct |
238 ms |
34592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1070 ms |
115488 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1090 ms |
115564 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
527 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
538 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
558 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
556 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
494 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
552 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
401 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
403 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |