# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
373602 | randomjohnnyh | A Huge Tower (CEOI10_tower) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 9;
int 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()); //sort the blocks
ll r = 0, sol = 1;
for (int l = 0; l < n; l++) {
while (r < n - 1 && ar[r + 1] - ar[l] <= d) r++;
int dist = r - l + 1; //largest tower we can built when ar[l] block is the base
sol = (sol * 1LL * dist) % MOD;
}
cout << sol << '\n';
}