Submission #326562

# Submission time Handle Problem Language Result Execution time Memory
326562 2020-11-15T07:59:44 Z shliao A Huge Tower (CEOI10_tower) Java 11
30 / 100
825 ms 50684 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 = N-1;
		for(int i = N-1; i>=0; i--) {
			while(j>=0 && blocks[i]-blocks[j]<=D) j--;
			stack[i] = i-j;
		}
		
		int ans = 1;
		
		for(int i = N-1; i>=0; i--)
		{
			ans = (ans*stack[i]) % mod;
		}
		
		System.out.println(ans);
		
		
		
	}
}
# Verdict Execution time Memory Grader output
1 Correct 74 ms 8476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 8448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 110 ms 8660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 85 ms 8528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 8556 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 85 ms 8544 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 92 ms 8736 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 74 ms 8508 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 75 ms 8556 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 79 ms 8576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 94 ms 8636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 8656 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 80 ms 8676 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 96 ms 8592 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 124 ms 9720 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 335 ms 17468 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 439 ms 19576 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 825 ms 24376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 637 ms 35372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 709 ms 50684 KB Output isn't correct
2 Halted 0 ms 0 KB -