Submission #249853

# Submission time Handle Problem Language Result Execution time Memory
249853 2020-07-16T05:56:10 Z kshitij_sodani A Huge Tower (CEOI10_tower) C++14
100 / 100
175 ms 14020 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first 
#define b second

llo n,d;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>d;
	vector<llo> aa;
	for(llo i=0;i<n;i++){
		llo bb;
		cin>>bb;
		aa.pb(bb);
	}
	sort(aa.begin(),aa.end());
	llo ans=1;
	llo mod=1e9+9;
	for(llo i=1;i<n;i++){
		if(aa[i-1]<aa[i]-d){
			continue;
		}
		llo x=lower_bound(aa.begin(),aa.end(),aa[i]-d)-aa.begin();

		ans*=(i-x+1);
		ans%=mod;

	}
	cout<<ans<<endl;




	return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1536 KB Output is correct
2 Correct 12 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 75 ms 4844 KB Output is correct
2 Correct 70 ms 4848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 164 ms 14020 KB Output is correct
2 Correct 175 ms 13536 KB Output is correct