Submission #468631

# Submission time Handle Problem Language Result Execution time Memory
468631 2021-08-29T05:46:45 Z Vectorized Balloons (CEOI11_bal) Java 11
50 / 100
2000 ms 31276 KB
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
1 Correct 103 ms 9744 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 105 ms 9684 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 205 ms 10448 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 713 ms 18348 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 1637 ms 19864 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Execution timed out 2079 ms 31276 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2075 ms 30076 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 2083 ms 24832 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2072 ms 23728 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2083 ms 24636 KB Time limit exceeded
2 Halted 0 ms 0 KB -