# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
726411 | professionalACer | A Huge Tower (CEOI10_tower) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 1e9 + 9;
int main() {
int N, D;
cin >> N >> D;
int A[N];
for (auto &x : A) cin >> x;
sort(a.begin(), a.end());
int p = 0, ans = 1;
for (int i = 0; i < N; i++) {
while (p < N - 1 && a[p + 1] - a[i] <= d) p++;
int d = p - i + 1;
ans = (ans = ans * d) % mod;
}
cout << ans << endl;
}