답안 #571351

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
571351 2022-06-01T22:11:02 Z DylanSmith Balloons (CEOI11_bal) Java 11
컴파일 오류
0 ms 0 KB
import java.util.*;
import java.io.*;
public class Balloons {
    public static void main(String[] args) throws IOException {
        Reader in = new Reader();
        PrintWriter out = new PrintWriter(System.out);
        
        int N = in.nextInt();
        int[] x = new int[N];
        double[] r = new double[N];
        for (int i = 0; i < N; i++) {
            x[i] = in.nextInt();
            r[i] = in.nextInt();
        }
        Stack<Integer> stack = new Stack<>();
        for (int i = 0; i < N; i++) {
            while (!stack.isEmpty() && r[stack.peek()] <= r[i]) {
                if (Math.pow(x[i] - x[stack.peek()], 2) / (4.0 * r[stack.peek()]) < r[i]) {
                    r[i] = Math.pow(x[i] - x[stack.peek()], 2) / (4.0 * r[stack.peek()]);
                }
                stack.pop();
            }
            if (!stack.isEmpty() && Math.pow(x[i] - x[stack.peek()], 2) / (4.0 * r[stack.peek()]) < r[i]) {
                r[i] = Math.pow(x[i] - x[stack.peek()], 2) / (4.0 * r[stack.peek()]);
            }
            stack.push(i);
        }
        for (int i = 0; i < N; i++) {
            out.printf("%.3f%n", r[i]);
        }
        
        out.close();
    }
    static class Reader {
        BufferedInputStream in;
        public Reader() {
            in = new BufferedInputStream(System.in);
        }
        public String nextLine() throws IOException {
            int c;
            StringBuilder sb = new StringBuilder("");
            while ((c = in.read()) != '\n')
                sb.append((char)(c));
            return sb.toString();
        }
        public String next() throws IOException {
            int c;
            StringBuilder sb = new StringBuilder("");
            while ((c = in.read()) != ' ' && c != '\n')
                sb.append((char)(c));
            return sb.toString();
        }
        public int nextInt() throws IOException {
            return (int)nextLong();
        }
        public long nextLong() throws IOException {
            int c;
            long res = 0;
            boolean start = false, negative = false;
            while ((c = in.read()) != ' ' && c != '\n' || !start)
                if (c >= '0' && c <= '9' || c == '-') {
                    start = true;
                    if (c == '-')
                        negative = true;
                    else
                        res = res * 10 + c - '0';
                }
            return res * (negative ? -1 : 1);
        }
    }
    public static void sort(int[] arr) {
        List<Integer> list = new ArrayList<>();
        for (int i : arr) {
            list.add(i);
        }
        Collections.sort(list);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = list.get(i);
        }
    }
}

Compilation message

bal.java:3: error: class Balloons is public, should be declared in a file named Balloons.java
public class Balloons {
       ^
1 error