菜鸡.jpg
CODE
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 620005;
int n, d, a[MAXN];
int main() {
scanf("%d%d", &n, &d);
for(int i = 1; i <= n; ++i)
scanf("%d", &a[i]);
sort(a + 1, a + n + 1);
int pt = 1, ans = 1;
for(int i = 2; i <= n; ++i) {
while(pt <= n && a[pt]+d < a[i]) ++pt;
ans = 1ll * ans * (i-pt+1) % 1000000009;
}
printf("%d
", ans);
}