| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1326568 | jim_x | A Huge Tower (CEOI10_tower) | C++17 | 0 ms | 0 KiB |
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <numeric>
#include <queue>
#include <stack>
#include <iomanip>
#include <array>
#include <functional>
#include <bitset>
using namespace std;
void baseIO(string s = ""){
ios_base::sync_with_stdio(0);
cin.tie(0);
if (s.size()){
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
}
int mod = 1e9 + 9;
int main() {
baseIO();
int n, d;
cin >> n >> d;
vector<int> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
sort(a.begin(), a.end());
long long ans = 1;
for (int i = 1; i < n; i++){
int ok = 1 + i - (lower_bound(a.begin(), a.begin() + i, a[i] - d) - a.begin());
ans = (ans * ok) % mod;
}
cout << ans << endl;
return 0;
}
