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 prob "C"
using namespace std;
const int maxn = 1e5;
const int MOD = 1e9 + 9;
int main(){
// freopen(prob".inp","r",stdin);
// freopen(prob".out","w",stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int n;
long long d;
cin >> n >> d;
vector<long long> a(n);
for(int i=0;i<n;i++) cin >> a[i];
sort(a.begin(),a.end());
long long res = 1;
for(int i=0;i<n;i++){
int L = 0, R = i-1, choose = -1;
while(L <= R){
int mid = (L + R) >> 1;
if(a[mid] + d >= a[i]){
choose = mid;
R = mid - 1;
}
else{
L = mid + 1;
}
}
if(choose == -1) continue;
res = res * 1ll * (i - choose + 1) % MOD;
// cout << i << " " << choose << " " << endl;
}
cout << res;
}
# | 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... |