# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
654072 | atharvd | A Huge Tower (CEOI10_tower) | C++14 | 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>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<fstream>
#define for_n(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define mp(i, j) make_pair(i, j)
typedef long long ll;
using namespace std;
int main(){
int n, d;
cin >> n >> d;
int arr[n];
for(int i = 0; i < n; i++){
cin >> arr[i];
}
sort(arr, arr + n);
int l = 0;
int w = 0;
ll count = 1;
const mod = 1000000009;
for(int r=0;r < n;r++) {
for(;l < r;l++) {
if(arr[r]-arr[l] <= d) break;
w--;
}
w++;
count *= w;
count %= mod;
}
cout << count << endl;
}