Submission #727139

# Submission time Handle Problem Language Result Execution time Memory
727139 2023-04-20T05:27:26 Z dn4271 A Huge Tower (CEOI10_tower) Java 11
Compilation error
0 ms 0 KB
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int d = input.nextInt();
		int[] blocks = new int[n];
		for (int i = 0; i < n; i++) {
			blocks[i] = input.nextInt();
		}
		
		Arrays.sort(blocks);
		
		int[] tolerance = new int[n];
		tolerance[0] = 1;
		for (int i = 1; i < n; i++) {
			int j = 0;
			while (blocks[i] - blocks[j] > d) {
				j++;
			} 
			tolerance[i] = i - j + 1;
		}
		
		int answer = 1;
		
		for (int i: tolerance) {
			answer = answer * i;
		}
		
		System.out.println(answer);
	}

}

Compilation message

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