Submission #800858

#TimeUsernameProblemLanguageResultExecution timeMemory
800858CallieBalloons (CEOI11_bal)Java
100 / 100
1636 ms34024 KiB
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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...