Submission #365123

# Submission time Handle Problem Language Result Execution time Memory
365123 2021-02-10T23:01:59 Z dg2004 A Huge Tower (CEOI10_tower) Java 11
Compilation error
0 ms 0 KB
import java.util.*;
import java.io.*;

public class Solution {
	static int MOD = 1000000009;
	
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer token = new StringTokenizer(in.readLine());
		int n = Integer.parseInt(token.nextToken()), d = Integer.parseInt(token.nextToken());
		int[] ar = new int[n];
		token = new StringTokenizer(in.readLine());
	    for (int a = 0; a < n; a++)
	        ar[a] = Integer.parseInt(token.nextToken());
	    Arrays.sort(ar);
	    int r = 0;
	    int ans = 1;
	    for (int l = 0; l < n; l++) {
	        while (r < n - 1 && ar[r + 1] - ar[l] <= d)
	        	r++; 
	        int dist = r - l + 1;
	        ans = (int)(((long)ans * dist) % MOD);
	    }
	    System.out.println(ans);
	}
}

Compilation message

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