import java.util.*;
import java.io.*;
public class tower {
static final int MOD = (int)1e9 + 9;
static Kattio io = new Kattio();
public static void main(String[] args) throws IOException {
int n = io.nextInt();
int d = io.nextInt();
int[] b = new int[n];
for(int i = 0; i < n; i++) {
b[i] = io.nextInt();
}
Arrays.sort(b);
long ans = 1;
int lowerP = 0;
for(int i = 1; i < n; i++) {
while(b[lowerP] < b[i] - d) {
lowerP++;
}
ans *= (i - lowerP + 1);
ans %= MOD;
}
io.println(ans);
io.close();
}
static class Kattio extends PrintWriter {
private BufferedReader r;
private StringTokenizer st;
public Kattio() { this(System.in,System.out); }
public Kattio(InputStream i, OutputStream o) {
super(o);
r = new BufferedReader(new InputStreamReader(i));
}
public Kattio(String problemName) throws IOException {
super(new FileWriter(problemName+".out"));
r = new BufferedReader(new FileReader(problemName+".in"));
}
public String next() {
try {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(r.readLine());
return st.nextToken();
} catch (Exception e) {}
return null;
}
public int nextInt() { return Integer.parseInt(next()); }
public double nextDouble() { return Double.parseDouble(next()); }
public long nextLong() { return Long.parseLong(next()); }
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
8848 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
8360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
8228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
8324 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
8368 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
60 ms |
8260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
69 ms |
8088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
8332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
8480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
73 ms |
8204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
64 ms |
8552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
8608 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
75 ms |
8296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
8400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
91 ms |
9436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
284 ms |
16948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
301 ms |
19456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
604 ms |
24400 KB |
Output is correct |
2 |
Correct |
610 ms |
24256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
500 ms |
36304 KB |
Output is correct |
2 |
Correct |
463 ms |
36308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
522 ms |
52136 KB |
Output is correct |
2 |
Correct |
577 ms |
50980 KB |
Output is correct |