Submission #238973

# Submission time Handle Problem Language Result Execution time Memory
238973 2020-06-13T20:29:10 Z dolphingarlic A Huge Tower (CEOI10_tower) C++14
100 / 100
162 ms 8856 KB
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

const ll MOD = 1e9 + 9;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, d;
    cin >> n >> d;
    vector<int> a(n);
    FOR(i, 0, n) cin >> a[i];
    sort(a.begin(), a.end());

    ll ans = 1;
    int ptr = 0;
    FOR(i, 0, n) {
        while (a[i] - a[ptr] > d) ptr++;
        ans = (ans * (i - ptr + 1)) % MOD;
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 1024 KB Output is correct
2 Correct 17 ms 1024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 3832 KB Output is correct
2 Correct 64 ms 3960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 162 ms 8856 KB Output is correct
2 Correct 153 ms 8184 KB Output is correct