Submission #365125

# Submission time Handle Problem Language Result Execution time Memory
365125 2021-02-10T23:04:27 Z dg2004 A Huge Tower (CEOI10_tower) Java 11
100 / 100
728 ms 45948 KB
import java.util.*;
import java.io.*;

public class tower {
	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);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 70 ms 8808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 8664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 8552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 8556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 75 ms 8600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 8556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 75 ms 8576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 82 ms 8808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 8548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 79 ms 8536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 75 ms 8536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 74 ms 8560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 8536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 8684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 104 ms 9560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 282 ms 17432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 368 ms 19408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 728 ms 23832 KB Output is correct
2 Correct 709 ms 23360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 590 ms 33608 KB Output is correct
2 Correct 590 ms 33612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 650 ms 45948 KB Output is correct
2 Correct 706 ms 45432 KB Output is correct