#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include<debug.h>
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif
using ll = long long;
using pii = pair<int,int>;
using db = double;
#define el cout << '\n'
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FOD(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
template <class T1, class T2>void chmax(T1 &a, T2 b){a = max(a, b);}
template <class T1, class T2>void chmin(T1 &a, T2 b){a = min(a, b);}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod = 1e9 + 9;;
template<typename T> T inv(T a, T m){ T u = 0, v = 1; while (a != 0) { T t = m / a; m -= t * a; swap(a, m); u -= t * v; swap(u, v); } assert(m == 1); return u; }
template<typename T>
class Modular{
public:
long long x;
constexpr Modular() {}
template<typename U> Modular(U x){if(x < 0) x += mod(); this->x = x; }
constexpr long long& operator()(){return x;}
template<typename U> explicit operator U() const {return static_cast<U>(x);}
constexpr static long long mod(){return T::value;}
Modular& operator+= (const Modular &a){ x += a.x; if(x >= mod()) x -= mod(); return *this; }
template<typename U> Modular& operator+=(const U& a){ return *this += Modular(a); }
Modular& operator-= (const Modular &a){ x -= a.x; if(x < 0) x += mod(); return *this; }
template<typename U> Modular& operator-=(const U& a){ return *this -= Modular(a); }
Modular& operator*= (const Modular &a){ x = (x % mod()) * (a.x % mod()); x %= mod(); return *this; }
Modular& operator/= (const Modular &a){ return *this *= Modular(inv(a.x, mod())); }
Modular& operator++(){ return *this += 1; }
Modular operator++(int) { Modular res(*this); *this += 1; return res; }
Modular& operator--(){ return *this -= 1; }
Modular operator--(int){ Modular res(*this); *this -= 1; return res;}
Modular operator-() const {return Modular(-x);}
template<typename U> friend std::ostream& operator<<(std::ostream& out, const Modular<U> &b);
template<typename U> friend std::istream& operator>>(std::istream& in, Modular<U>& b);
};
template<typename T> Modular<T> operator+(const Modular<T>& a, const Modular<T>& b){ return Modular<T>(a) += b; }
template<typename T, typename U> Modular<T> operator+(const Modular<T>& a, U b){ return Modular<T>(a) += b; }
template<typename T, typename U> Modular<U> operator+(T a, const Modular<U>& b){ return Modular<U>(a) += b; }
template<typename T> Modular<T> operator-(const Modular<T>& a, const Modular<T>& b){ return Modular<T>(a) -= b; }
template<typename T, typename U> Modular<T> operator-(const Modular<T>& a, U b){ return Modular<T>(a) -= b; }
template<typename T, typename U> Modular<U> operator-(T a, const Modular<U>& b){ return Modular<U>(a) -= b; }
template<typename T> Modular<T> operator*(const Modular<T>& a, const Modular<T>& b){ return Modular<T>(a) *= b; }
template<typename T, typename U> Modular<T> operator*(const Modular<T>& a, U b){ return Modular<T>(a) *= b; }
template<typename T, typename U> Modular<U> operator*(T a, const Modular<U>& b){ return Modular<U>(a) *= b; }
template<typename T> Modular<T> operator/(const Modular<T>& a, const Modular<T>& b){ return Modular<T>(a) /= b; }
template<typename T, typename U> Modular<T> operator/(const Modular<T>& a, U b){ return Modular<T>(a) /= b; }
template<typename T, typename U> Modular<U> operator/(T a, const Modular<U>& b){ return Modular<U>(a) /= b; }
template<typename T, typename U>
Modular<T> Pow(const Modular<T>& a, const U& b){ assert(b >= 0); Modular<T> x = a,res = 1; U p = b; while(p){ if(p & 1) res *= x; x *= x; p >>= 1; } return res; }
template<typename T> std::ostream& operator<<(std::ostream& out, const Modular<T> &a){ out << a.x; return out; }
template<typename T> std::istream& operator>>(std::istream& in, Modular<T> &a){ in >> a.x; a.x %= Modular<T>::mod(); return in; }
template<typename T> string to_string(const Modular<T> &a){ return to_string((int) a); }
using Mint = Modular<std::integral_constant<decay<decltype(mod)>::type, mod>>;
const int maxn = 1e4;
Mint f[maxn];
void solve(){
int n, k;
cin >> n >> k;
vector<int> x(n);
for (auto& a : x) cin >> a;
sort(x.rbegin(), x.rend());
Mint ans = 1;
int cur = 1;
FOR(i, 1, n - 1){
if (x[i - 1] - x[i] > k){
ans *= f[cur];
cur = 1;
}
else cur++;
}
cerr << cur;
ans *= f[cur];
cout << ans;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tests = 1;
//cin >> tests;
f[1] = 1;
for (int i = 2; i < maxn; i++) f[i] = i * f[i - 1];
for (int itest = 1; itest <= tests; itest++){
cerr << "- TEST " << itest << ": \n";
solve();
el;
}
return 0;
}
Compilation message
tower.cpp:6:9: fatal error: debug.h: No such file or directory
6 | #include<debug.h>
| ^~~~~~~~~
compilation terminated.