Submission #405686

# Submission time Handle Problem Language Result Execution time Memory
405686 2021-05-16T18:11:57 Z four_specks A Huge Tower (CEOI10_tower) C++17
100 / 100
204 ms 8732 KB
#include <bits/stdc++.h>

using namespace std;

const int mod = 1'000'000'009;

void solve()
{
    int n;
    long d;
    cin >> n >> d;

    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a.begin(), a.end());

    long c = 1;
    for (int i = 0; i < n; i++)
    {
        int x = i + 1 - (lower_bound(a.begin(), a.end(), a[i] - d) - a.begin());
        c *= x;
        c %= mod;
    }

    cout << c << '\n';
}

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

    solve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 972 KB Output is correct
2 Correct 13 ms 868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 3652 KB Output is correct
2 Correct 56 ms 3712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 151 ms 8732 KB Output is correct
2 Correct 204 ms 8088 KB Output is correct