Submission #1178886

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

public class AHugeTower {
	static final int MOD = 1000000009;
	public static void main(String[] args) {
		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 right = 0;
		int res = 0;
		for (int left = 0; left < n; left++) {
			while (right < n - 1 && blocks[right + 1] - blocks[left] <= d) {
				right++;
			}

			int dist = right - left + 1;
			res = (int)(res * (long) dist) % MOD;
		}
		
		io.close();
	}

	// CodeSnip{Kattio}

	static 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(problemName + ".out");
			r = new BufferedReader(new FileReader(problemName + ".in"));
		}
		// 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 AHugeTower is public, should be declared in a file named AHugeTower.java
public class AHugeTower {
       ^
1 error

=======