#include<bits/stdc++.h>
#define int long long
#define ld double
#define _1 first
#define _2 second
#define yes cout<<"Yes\n"
#define nah cout<<"No\n"
#define FFF ios_base::sync_with_stdio(0);cin.tie(0);
#define ipr pair<int,int>
#define ret return
#define intt int32_t
#define mid ((l+r)/2)
#define pb push_back
#define lll __int128
using namespace std;
int tst, ts;
const intt mo = 1e9+7, dx[] = {-1, 1, 0, 0,-1,-1,1,1}, dy[] = {0, 0, -1, 1,-1,1,-1,1};
int mul( int x, int y ) {
ret ( ( x % mo ) * ( y % mo ) ) % mo;
ret x*y;
}
int pwo( int x, int y ) {
int res = 1;
for( int i = 63; i + 1; i-- )
res = mul( res, res * ( ( 1ll << i )&y ? x : 1 ) );
ret res;
}
int dvii( int x, int y ) {
ret mul( x, pwo( y, mo - 2 ) );
}
int oo( char x ) {
ret ( int )x - '0';
}
int lgg( int x, int y ) {
int u = 0;
while( x ) {
u++;
x /= y;
}
ret u;
}
int mun( int x, int y ) {
while( x < y )x += mo;
ret ( x - y ) % mo;
}
int add( int x, int y ) {
ret x + y - ( mo * ( x + y >= mo ) );
ret x + y;
}
int lcm( int x, int y ) {
ret ( x * y ) / __gcd( x, y );
}
#define endl '\n';
const int M =4007, N = 5e5 + 7, N2 = 5e3 + 7, inf = 2e18 + 7;
int n,m,a[N],b[N];
string s;
void solve(){
cin>>n>>m;
for(int i=0;i<n;i++)
cin>>a[i];
sort(a,a+n);
reverse(a,a+n);
int ans=1;
for(int i=0;i<n;i++){
int l=i,r=n;
while(r-l>1)
if(a[mid]+m<a[i])
r=mid;
else
l=mid;
ans=mul(ans,r-i);
}
cout<<ans<<endl;
}
intt main() {
FFF
//freopen("revegetate.in", "r", stdin);
//freopen("revegetate.out", "w", stdout);
tst = 1;
//cin >> tst;
for ( ts = 1; ts <= tst; ts++ ) {
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |