Submission #855338

# Submission time Handle Problem Language Result Execution time Memory
855338 2023-10-01T06:01:53 Z magikrap A Huge Tower (CEOI10_tower) C++14
100 / 100
234 ms 10020 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <cstring>
#include <bitset>
#include <string>

#define ll long long

using namespace std;

ll N, D;
vector<ll> a;
ll MOD = 1e9+9;

int main() {
    cin >> N >> D;
    a.resize(N);
    for (ll i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ll ans = 1;
    for (ll i = 1; i < N; i++) {
        ll idx = lower_bound(a.begin(), a.end(), a[i]-D) - a.begin();
        ans *= (i-idx+1);
        ans %= MOD;
    }
    cout << ans << endl;
}
# 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 0 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 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 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 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 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 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 4 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 604 KB Output is correct
2 Correct 17 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 126 ms 2396 KB Output is correct
2 Correct 88 ms 4684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 211 ms 5272 KB Output is correct
2 Correct 234 ms 10020 KB Output is correct