Submission #135475

# Submission time Handle Problem Language Result Execution time Memory
135475 2019-07-24T06:19:09 Z imeimi2000 A Huge Tower (CEOI10_tower) C++17
100 / 100
177 ms 3576 KB
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long llong;

const int mod = 1e9 + 9;
int n, d;
int A[1000000];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> d;
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    sort(A, A + n);
    int ans = 1;
    for (int i = 0; i < n; ++i) {
        int x = lower_bound(A, A + n, A[i] - d) - A;
        ans = ans * (i + 1ll - x) % mod;
    }
    printf("%d\n", ans);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 1080 KB Output is correct
2 Correct 14 ms 1036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 74 ms 2204 KB Output is correct
2 Correct 61 ms 2172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 136 ms 3576 KB Output is correct
2 Correct 177 ms 3572 KB Output is correct