Submission #532732

#TimeUsernameProblemLanguageResultExecution timeMemory
532732Cubik65536A Huge Tower (CEOI10_tower)Java
Compilation error
0 ms0 KiB
import java.io.*;
import java.util.*;

public class Main {
    private static final int MOD = (int) 1e9 + 9;

    public static void main(String[] args) throws IOException {
        Kattio io = new Kattio();

        int n = io.nextInt();
        int d = io.nextInt();

        int[] blocks = new int[n];
        for (int i = 0; i < n; i++) {
            blocks[i] = io.nextInt();
        }

        Arrays.sort(blocks);

        int result = 1;
        for (int i = 0, j = 0; i < n; i++) {
            while (j < n - 1 && blocks[j + 1] - blocks[i] <= d) {
                j++;
            }
            int dist = j - i + 1;
            result = (result * dist) % MOD;
        }

        io.println(result);

        io.close();
    }
}

class Kattio extends PrintWriter {
    private BufferedReader r;
    private StringTokenizer st;

    // standard input
    public Kattio() {
        this(System.in, System.out);
    }

    public Kattio(InputStream i, OutputStream o) {
        super(o);
        r = new BufferedReader(new InputStreamReader(i));
    }

    // USACO-style file input
    public Kattio(String problemName) throws IOException {
        super(new FileWriter(problemName + ".out"));
        r = new BufferedReader(new FileReader(problemName + ".in"));
    }

    // read next line
    public String readLine() {
        try {
            return r.readLine();
        } catch (IOException e) {
        }
        return null;
    }

    // returns null if no more input
    public String next() {
        try {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(r.readLine());
            return st.nextToken();
        } catch (Exception e) {
        }
        return null;
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }
}

Compilation message (stderr)

tower.java:4: error: class Main is public, should be declared in a file named Main.java
public class Main {
       ^
1 error