Submission #716634

# Submission time Handle Problem Language Result Execution time Memory
716634 2023-03-30T15:33:33 Z stevancv A Huge Tower (CEOI10_tower) C++14
100 / 100
138 ms 8748 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 1e5 + 2;
const int inf = 1e9;
const int mod = 1e9 + 9;
ll Mul(ll a, ll b) {
    ll c = a; c *= b; c %= mod;
    return c;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.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());
    ll ans = 1;
    int j = 0;
    for (int i = 1; i < n; i++) {
        while (j < i && a[j] + d < a[i]) j++;
        ans = Mul(ans, i - j + 1);
    }
    cout << ans << en;
    return 0;
}
# 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 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 324 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 316 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 316 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 340 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 3 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 896 KB Output is correct
2 Correct 12 ms 900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 3712 KB Output is correct
2 Correct 53 ms 3732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 138 ms 8748 KB Output is correct
2 Correct 121 ms 8108 KB Output is correct