# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1010186 | Petrix | 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>
#include <algorithm>
using namespace std;
#define MOD 1000000009
long long v[10000001];
int main()
{
long long n,m,i,rasp,st;
cin>>n>>m;
for(i=1;i<=n;i++) cin>>v[i];
sort(v+1,v+n+1);
rasp=1;st=1;
for(i=1;i<=n;i++){
while(st<i && v[st]+m<v[i])
st++;
rasp=(rasp*(i-st+1))%MOD;
}
cout<<rasp;
return 0;
}
#include <iostream>
#include <algorithm>
using namespace std;
#define MOD 1000000009
long long v[10000001];
int main()
{
long long n,m,i,rasp,st;
cin>>n>>m;
for(i=1;i<=n;i++) cin>>v[i];
sort(v+1,v+n+1);
rasp=1;st=1;
for(i=1;i<=n;i++){
while(st<i && v[st]+m<v[i])
st++;
rasp=(rasp*(i-st+1))%MOD;
}
cout<<rasp;
return 0;
}