Submission #1110801

# Submission time Handle Problem Language Result Execution time Memory
1110801 2024-11-10T14:02:23 Z Thunnus A Huge Tower (CEOI10_tower) C++17
100 / 100
98 ms 11184 KB
#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
#define int i64
#define vi vector<int>
#define vvi vector<vi>
#define vb vector<bool>
#define pii pair<int, int>
#define fi first
#define se second
#define sz(x) (int)(x).size()

const int MOD = 1e9 + 9;

inline void solve(){
    int n, d, ans = 1;
    cin >> n >> d;
    vi a(n);
    for(int &i : a){
        cin >> i;
    }
    sort(a.begin(), a.end());

    for(int le = 0, ri = 0; le < n; le++){
        while(ri < n - 1 && a[ri + 1] - a[le] <= d) ri++;
        ans = (ans * (ri - le + 1)) % MOD;
    }
    cout << ans << "\n";
    return;
}

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1476 KB Output is correct
2 Correct 12 ms 1240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 4832 KB Output is correct
2 Correct 36 ms 4704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 78 ms 11184 KB Output is correct
2 Correct 98 ms 10568 KB Output is correct