# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1066733 |
2024-08-20T05:56:56 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 {
BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer l1 = new StringTokenizer(scan.readLine()); num = Integer.parseInt(l1.nextToken()); int L = Integer.parseInt(l1.nextToken()); arr = new double[num][2];
for (int i = 0;i<num;i++) {
StringTokenizer st = new StringTokenizer(scan.readLine());
arr[i][0] = Integer.parseInt(st.nextToken());
arr[i][1] = Integer.parseInt(st.nextToken());
}
double l = 0; double h = Math.pow(10,9);
while (h-l>Math.pow(10,-3)) {
double mid = (l+h)/2; boolean work = true;
ArrayList<Pair> endpoints = getEndpoints(mid);
endpoints.sort(Comparator.comparingDouble(i -> i.l));
/*System.out.println(" "+mid);
for (int i = 0;i<endpoints.size();i++) {
System.out.println(endpoints.get(i).l+" "+endpoints.get(i).r);
}
System.out.println("--------");*/
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++) {
double newL = endpoints.get(i).l;
if (newL>right&&newL>0&&newL<L) work = false;
left = Math.min(left, endpoints.get(i).l); right = Math.max(right, endpoints.get(i).r);
}
work = (work)&&(left<=0&&right>=L);
if (work) h = mid;
else l = mid;
}
System.out.println((l+h)/2);
}
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;
endpoints.add(new Pair(arr[i][0]-Math.sqrt(r*r-arr[i][1]*arr[i][1]),
arr[i][0]+Math.sqrt(r*r-arr[i][1]*arr[i][1])));
}
return endpoints;
}
public static class Pair {
double l; double r;
public Pair (double l, double r) {
this.l = l; this.r = r;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
9580 KB |
Output is correct |
2 |
Correct |
60 ms |
9592 KB |
Output is correct |
3 |
Correct |
62 ms |
9868 KB |
Output is correct |
4 |
Correct |
58 ms |
9564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
82 ms |
10328 KB |
Output is correct |
2 |
Correct |
83 ms |
10576 KB |
Output is correct |
3 |
Correct |
71 ms |
10024 KB |
Output is correct |
4 |
Correct |
73 ms |
10068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
251 ms |
16312 KB |
Output is correct |
2 |
Correct |
194 ms |
15484 KB |
Output is correct |
3 |
Correct |
224 ms |
15336 KB |
Output is correct |
4 |
Correct |
209 ms |
15172 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
301 ms |
15700 KB |
Output is correct |
2 |
Correct |
213 ms |
15048 KB |
Output is correct |
3 |
Correct |
318 ms |
16904 KB |
Output is correct |
4 |
Correct |
279 ms |
15884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
305 ms |
16216 KB |
Output is correct |
2 |
Correct |
211 ms |
15560 KB |
Output is correct |
3 |
Correct |
375 ms |
16604 KB |
Output is correct |
4 |
Correct |
308 ms |
15864 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
266 ms |
15256 KB |
Output is correct |
2 |
Correct |
213 ms |
15384 KB |
Output is correct |
3 |
Correct |
417 ms |
16768 KB |
Output is correct |
4 |
Correct |
260 ms |
15876 KB |
Output is correct |
5 |
Correct |
320 ms |
16344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
516 ms |
27976 KB |
Output is correct |
2 |
Correct |
762 ms |
30920 KB |
Output is correct |
3 |
Correct |
563 ms |
24612 KB |
Output is correct |
4 |
Correct |
564 ms |
28536 KB |
Output is correct |
5 |
Correct |
619 ms |
24312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
661 ms |
28772 KB |
Output is correct |
2 |
Correct |
656 ms |
29852 KB |
Output is correct |
3 |
Correct |
602 ms |
28912 KB |
Output is correct |
4 |
Correct |
545 ms |
30044 KB |
Output is correct |
5 |
Correct |
552 ms |
30308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
512 ms |
28752 KB |
Output is correct |
2 |
Correct |
920 ms |
32044 KB |
Output is correct |
3 |
Correct |
499 ms |
29808 KB |
Output is correct |
4 |
Correct |
536 ms |
31336 KB |
Output is correct |
5 |
Correct |
691 ms |
30100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
699 ms |
31352 KB |
Output is correct |
2 |
Correct |
929 ms |
35784 KB |
Output is correct |
3 |
Correct |
885 ms |
33252 KB |
Output is correct |
4 |
Correct |
477 ms |
31092 KB |
Output is correct |
5 |
Correct |
691 ms |
33116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
630 ms |
30776 KB |
Output is correct |
2 |
Correct |
934 ms |
36124 KB |
Output is correct |
3 |
Correct |
768 ms |
33544 KB |
Output is correct |
4 |
Correct |
500 ms |
31044 KB |
Output is correct |
5 |
Correct |
624 ms |
33060 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1014 ms |
113644 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1057 ms |
111024 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1004 ms |
128204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1029 ms |
116740 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
576 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1034 ms |
118060 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
745 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1006 ms |
131072 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
599 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
954 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |