# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
383795 | wabadabakalakaboo | 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 <iostream>
using namespace std;
long long n, d, a[1000005], p = 1;
int main() {
cin >> n >> d;
for (int i = 0; i < n; i++) cin >> a[i];
sort(a,a+n);
for (int i = 0, j = 0; i < n; i++) {
for (; a[i]-d > a[j]; j++);
p = (p * (i-j+1)) % 1000000009;
}
cout << p;
}