#include <iostream>
#include <fstream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
// ofstream fout ("split.out");
// ifstream fin ("split.in");
int main(){
int n,d;
cin>>n>>d;
int array[n];
long long product=1;
for(int i=0;i<n;i++){
cin>>array[i];
}
int j=0;
sort(array,array+n);
for(int i=0;i<n;i++){
while(j<i&&array[j]+d<array[i]){
j++;
}
int dist=i-j+1;
product=(product*dist)%1000000009;
}
// for(int i=n-1;i>=0;i--){
// int j=i-1;
// while(array[i]<=d+array[j]){
// j--;
// }
// product=product*(i-j)%1000000009;
// }
// cout<<product;
// long long product=1;
// for(int i=0;i<n;i++){
// cout<<barray[i]<<endl;
// }
// for(int i=0;i<n;i++){
// product*=(barray[i]+1);
// }
cout<<product;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
604 KB |
Output is correct |
2 |
Correct |
15 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
73 ms |
1616 KB |
Output is correct |
2 |
Correct |
73 ms |
1368 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
145 ms |
2652 KB |
Output is correct |
2 |
Correct |
147 ms |
2648 KB |
Output is correct |