Submission #1103109

# Submission time Handle Problem Language Result Execution time Memory
1103109 2024-10-20T05:44:52 Z zephyrion A Huge Tower (CEOI10_tower) C++17
100 / 100
93 ms 6992 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int mxN=1e7,MOD=1e9+9;
 
int N,D,a[mxN],c[mxN],res=1;
 
signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	
	cin>>N>>D;
	for (int i=0; i<N; i++)
		cin>>a[i];
	sort(a,a+N);
	for (int l=0,r=0; l<N; l++)
		for (; r<N && a[r]-a[l]<=D; r++)
			res=res*(r-l+1)%MOD;
	cout<<res;
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2384 KB Output is correct
2 Correct 7 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 4576 KB Output is correct
2 Correct 40 ms 6992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 86 ms 6480 KB Output is correct
2 Correct 93 ms 6472 KB Output is correct