This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import java.util.Stack;
import java.util.StringTokenizer;
public class bal {
static class Node{
double x;
double r;
Node(double x, double r){
this.x = x;
this.r = r;
}
}
private static DecimalFormat df = new DecimalFormat("0.000");
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
Stack<Node> s = new Stack<Node>();
for (int i = 0; i < n; i++) {
st = new StringTokenizer(br.readLine());
double curx = Double.parseDouble(st.nextToken()), curr = Double.parseDouble(st.nextToken());
while (s.size() > 0){
double newr = 1.0 * (1.0 * (s.peek().x - curx) * (s.peek().x - curx)) / (4.0 * s.peek().r);
curr = Math.min(curr, newr);
if(curr > s.peek().r){
s.pop();
}else {
break;
}
}
System.out.println(df.format(curr));
s.add(new Node(curx, curr));
}
}
}
# | 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... |