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.*;
import java.util.*;
class Balloon {
public long x;
public double r;
public Balloon(long x, double r) {
this.x = x;
this.r = r;
}
public double calcR(long bx) {
return (x - bx) * (x - bx) / (4 * r);
}
}
public class bal {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int balloons = Integer.parseInt(in.readLine());
double[] answers = new double[balloons];
Stack<Balloon> s = new Stack<Balloon>();
for(int i = 0; i < balloons; i++) {
StringTokenizer st = new StringTokenizer(in.readLine());
long x = Integer.parseInt(st.nextToken());
double r = Integer.parseInt(st.nextToken());
double max = r;
while(!s.isEmpty()) {
double to = s.peek().calcR(x);
max = Math.min(max, to);
if(max >= s.peek().r) {
s.pop();
continue;
}
else break;
}
s.add(new Balloon(x, max));
answers[i] = max;
}
for(double i: answers) System.out.println(i);
}
}
# | 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... |