Submission #326850

# Submission time Handle Problem Language Result Execution time Memory
326850 2020-11-15T08:09:27 Z shliao A Huge Tower (CEOI10_tower) Java 11
100 / 100
924 ms 49676 KB
import java.io.*;
import java.util.*;

public class tower {
	static int mod = 1000000009;
	public static void main(String[]args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		StringTokenizer st = new StringTokenizer(br.readLine());
		int N = Integer.parseInt(st.nextToken());
		int D = Integer.parseInt(st.nextToken());
		
		st = new StringTokenizer(br.readLine());
		int[]blocks = new int[N];
		for(int i = 0; i<N; i++) {
			blocks[i] = Integer.parseInt(st.nextToken());
		}
		Arrays.sort(blocks);
		
		int[]stack = new int[N];
		
		int j = 0;
		for(int i = 0; i<N; i++) {
			while(j<N && blocks[j]-blocks[i]<=D) j++;
			stack[i] = j-i;
			
		}
		
		long ans = 1;
		for(int i = 0; i<N; i++) {
			ans = (stack[i]*ans)%mod;
		}
		
		System.out.println(ans);
		
		
		
	}
}
# Verdict Execution time Memory Grader output
1 Correct 70 ms 8556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 89 ms 8880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 77 ms 8484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 8492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 8532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 80 ms 8668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 8520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 82 ms 8684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 86 ms 8528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 80 ms 8640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 77 ms 8424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 8556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 95 ms 8548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 81 ms 8504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 114 ms 9684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 331 ms 17248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 473 ms 19304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 924 ms 23768 KB Output is correct
2 Correct 767 ms 23840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 624 ms 32732 KB Output is correct
2 Correct 675 ms 35136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 769 ms 44688 KB Output is correct
2 Correct 750 ms 49676 KB Output is correct