Submission #935990

# Submission time Handle Problem Language Result Execution time Memory
935990 2024-02-29T21:21:26 Z Ponda A Huge Tower (CEOI10_tower) C++17
100 / 100
92 ms 11168 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int mod = 1000000009, n, d; cin >> n >> d;
    vector<int> blocks(n);
    for (int i = 0; i < n; i++) {
        cin >> blocks[i];
    }
    sort(blocks.begin(), blocks.end());
    int ans = 1; int j = 0;
    for (int i = 0; i < n; i++) {
        while (j < n && blocks[i] + d >= blocks[j]) {
            j++;
        }
        ans = (ans * (j-i) % mod) % mod;
    }
    cout << ans << '\n';
    return 0;
}
# 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 1 ms 500 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 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 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 1 ms 460 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 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1484 KB Output is correct
2 Correct 7 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 4700 KB Output is correct
2 Correct 36 ms 4696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 81 ms 11168 KB Output is correct
2 Correct 92 ms 10680 KB Output is correct