Submission #726906

# Submission time Handle Problem Language Result Execution time Memory
726906 2023-04-19T14:07:30 Z techymonsterai A Huge Tower (CEOI10_tower) C++17
100 / 100
124 ms 8104 KB
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

constexpr int MOD = 1e9 + 9;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, d;
    cin >> n >> d;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    sort(a.begin(), a.end());
    long long ans = 1;
    for (int l = 0, r = 0; r < n; r++){
        while (a[r] - a[l] > d)
            l++;
        ans = (ans * (r - l + 1)) % MOD;
    }
    cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 980 KB Output is correct
2 Correct 51 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 3708 KB Output is correct
2 Correct 73 ms 3716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 99 ms 3408 KB Output is correct
2 Correct 124 ms 8104 KB Output is correct