# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
726412 | professionalACer | A Huge Tower (CEOI10_tower) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 1e9 + 9;
int main() {
int N, D;
cin >> N >> D;
int A[N];
for (auto &x : A) cin >> x;
sort(A.begin(), A.end());
int p = 0, ans = 1;
for (int i = 0; i < N; i++) {
while (p < N - 1 && A[p + 1] - A[i] <= D) p++;
int d = p - i + 1;
ans = (ans * d) % mod;
}
cout << ans << endl;
}