Submission #727148

# Submission time Handle Problem Language Result Execution time Memory
727148 2023-04-20T05:43:27 Z dn4271 A Huge Tower (CEOI10_tower) Java 11
85 / 100
1000 ms 24464 KB
import java.util.*;

public class tower {

	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;
		}
		
		long answer = 1;
		
		for (int i: tolerance) {
			answer = answer * i;
			answer = answer % (1000000009);
		}
		
		System.out.println(answer);
	}

}
# Verdict Execution time Memory Grader output
1 Correct 126 ms 9916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 107 ms 10020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 112 ms 10156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 119 ms 9948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 139 ms 9840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 111 ms 9848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 132 ms 10044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 134 ms 9892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 143 ms 9976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 126 ms 9948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 131 ms 10040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 111 ms 10096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 136 ms 10072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 117 ms 10096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 273 ms 12320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 393 ms 20488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 635 ms 23044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 24336 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1049 ms 24464 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1054 ms 20144 KB Time limit exceeded
2 Halted 0 ms 0 KB -