Submission #1082849

# Submission time Handle Problem Language Result Execution time Memory
1082849 2024-09-01T21:50:29 Z rcll A Huge Tower (CEOI10_tower) C++17
100 / 100
181 ms 11088 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int MOD=1e9+9;

signed main() {
	int n,d;
	cin >> n >> d;
	vector<int> ar(n);
	for (int i=0; i<n; i++) { 
        cin >> ar[i]; 
    }
	sort(ar.begin(),ar.end());
	int r=0, ans=1;
	for (int l=0; l<n; l++) {
		while (r<n-1 && ar[r+1]-ar[l]<=d) {
            r++;
        }
		int dist =r-l+1;
		ans=(ans*1LL*dist)%MOD;
	}
	cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 1116 KB Output is correct
2 Correct 16 ms 1304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 80 ms 4820 KB Output is correct
2 Correct 92 ms 4696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 180 ms 11088 KB Output is correct
2 Correct 181 ms 10580 KB Output is correct