답안 #740774

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
740774 2023-05-13T05:33:10 Z yeroc A Huge Tower (CEOI10_tower) Java 11
컴파일 오류
0 ms 0 KB
// File: HugeTower.java
// Date: 04/15/2023
// Author: Corey Zhu

import java.io.*;
import java.util.*;

public Tower {

    static void solve(Kattio io){
		int MOD = 1000000009;
		int n = io.nextInt(); int d = io.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = io.nextInt();
		}
		Arrays.sort(arr);
		long ans = 1;
		int end = 0;
		for (int i = 0; i < n-1; i++) {
			while (end < n && arr[end]-arr[i] <= d) {
				end += 1;
			}
			ans = ((long)(ans * (end-i))) % MOD;
			
		}
		io.println(ans);
    }

    // Run
    public static void main(String[] args) throws IOException {
        Kattio io = new Kattio();
        solve(io);
        io.close();
    }
    
    // IO
	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

tower.java:8: error: class, interface, or enum expected
public Tower {
       ^
tower.java:12: error: class, interface, or enum expected
		int n = io.nextInt(); int d = io.nextInt();
		^
tower.java:12: error: class, interface, or enum expected
		int n = io.nextInt(); int d = io.nextInt();
		                      ^
tower.java:13: error: class, interface, or enum expected
		int[] arr = new int[n];
		^
tower.java:14: error: class, interface, or enum expected
		for (int i = 0; i < n; i++) {
		^
tower.java:14: error: class, interface, or enum expected
		for (int i = 0; i < n; i++) {
		                ^
tower.java:14: error: class, interface, or enum expected
		for (int i = 0; i < n; i++) {
		                       ^
tower.java:16: error: class, interface, or enum expected
		}
		^
tower.java:18: error: class, interface, or enum expected
		long ans = 1;
		^
tower.java:19: error: class, interface, or enum expected
		int end = 0;
		^
tower.java:20: error: class, interface, or enum expected
		for (int i = 0; i < n-1; i++) {
		^
tower.java:20: error: class, interface, or enum expected
		for (int i = 0; i < n-1; i++) {
		                ^
tower.java:20: error: class, interface, or enum expected
		for (int i = 0; i < n-1; i++) {
		                         ^
tower.java:23: error: class, interface, or enum expected
			}
			^
tower.java:26: error: class, interface, or enum expected
		}
		^
tower.java:28: error: class, interface, or enum expected
    }
    ^
tower.java:31: error: class, interface, or enum expected
    public static void main(String[] args) throws IOException {
                  ^
tower.java:33: error: class, interface, or enum expected
        solve(io);
        ^
tower.java:34: error: class, interface, or enum expected
        io.close();
        ^
tower.java:35: error: class, interface, or enum expected
    }
    ^
tower.java:65: error: class, interface, or enum expected
}
^
21 errors