# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
746194 |
2023-05-21T21:11:14 Z |
rahulverma |
Balloons (CEOI11_bal) |
Java 11 |
|
2000 ms |
28460 KB |
import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
public class bal {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
int[] coord = new int[n];
int[] maxRad = new int[n];
double[] ans = new double[n];
for(int i = 0; i < n; i++) {
StringTokenizer st = new StringTokenizer(br.readLine());
coord[i] = Integer.parseInt(st.nextToken());
maxRad[i] = Integer.parseInt(st.nextToken());
}
ans[0] = maxRad[0];
Stack<Integer> stack = new Stack<Integer>();
stack.add(0); // indexes in the stack
for(int i = 1; i < n; i++) {
double pos = 0;
while(!stack.isEmpty()) {
int top = stack.peek();
if(dist(coord[top], ans[top], coord[i]) < maxRad[i]) {
stack.pop();
pos = dist(coord[top], ans[top], coord[i]);
}
else {
pos = maxRad[i];
break;
}
}
ans[i] = pos;
stack.add(i);
}
for(int i = 0; i < n; i++) {
System.out.format("%.3f", (round(ans[i], 3)));
System.out.println();
}
}
public static double dist(int x1, double r1, int x2) {
double x_1 = x1;
double x_2 = x2;
return (x_1 - x_2) * (x_1 - x_2) / (4*r1);
}
private static double round(double value, int places) {
if (places < 0) throw new IllegalArgumentException();
BigDecimal bd = new BigDecimal(Double.toString(value));
bd = bd.setScale(places, RoundingMode.HALF_UP);
return bd.doubleValue();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
73 ms |
10004 KB |
4th numbers differ - expected: '1.8420000000', found: '87.0000000000', error = '85.1580000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
9212 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
159 ms |
10064 KB |
3rd numbers differ - expected: '0.0420000000', found: '3.0000000000', error = '2.9580000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
543 ms |
18960 KB |
6th numbers differ - expected: '116.0020000000', found: '117.0000000000', error = '0.9980000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1504 ms |
21768 KB |
11th numbers differ - expected: '201.0010000000', found: '202.0000000000', error = '0.9990000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1625 ms |
23116 KB |
5th numbers differ - expected: '15395.0000000000', found: '15396.0000000000', error = '1.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1810 ms |
25444 KB |
14th numbers differ - expected: '7919.0000000000', found: '7920.0000000000', error = '1.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1897 ms |
26280 KB |
5th numbers differ - expected: '5054.0000000000', found: '5055.0000000000', error = '1.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2049 ms |
27516 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2055 ms |
28460 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |