# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
740775 | yeroc | A Huge Tower (CEOI10_tower) | Java | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// File: HugeTower.java
// Date: 04/15/2023
// Author: Corey Zhu
import java.io.*;
import java.util.*;
public class Main {
static void solve(Kattio io){
int MOD = 1000000009;
int n = io.nextInt(); int d = io.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = io.nextInt();
}
Arrays.sort(arr);
long ans = 1;
int end = 0;
for (int i = 0; i < n-1; i++) {
while (end < n && arr[end]-arr[i] <= d) {
end += 1;
}
ans = ((long)(ans * (end-i))) % MOD;
}
io.println(ans);
}
// Run
public static void main(String[] args) throws IOException {
Kattio io = new Kattio();
solve(io);
io.close();
}
// IO
static class Kattio extends PrintWriter {
private BufferedReader r;
private StringTokenizer st;
// standard input
public Kattio() { this(System.in, System.out); }
public Kattio(InputStream i, OutputStream o) {
super(o);
r = new BufferedReader(new InputStreamReader(i));
}
// USACO-style file input
public Kattio(String problemName) throws IOException {
super(problemName + ".out");
r = new BufferedReader(new FileReader(problemName + ".in"));
}
// returns null if no more input
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()); }
}
}