Submission #668735

# Submission time Handle Problem Language Result Execution time Memory
668735 2022-12-04T20:25:09 Z Dec0Dedd A Huge Tower (CEOI10_tower) C++14
100 / 100
311 ms 10520 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int N = 1e5+10;
const ll MOD = 1e9+9;

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

    ll ans=1, r=0;
    for (ll i=0; i<n; ++i) {
        r=max(i, r);
        while (r < n && a[i]+d >= a[r]) ++r;
        (ans*=r-i)%=MOD;
    } cout<<ans<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 5 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 596 KB Output is correct
2 Correct 23 ms 704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 147 ms 3524 KB Output is correct
2 Correct 138 ms 4664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 277 ms 10008 KB Output is correct
2 Correct 311 ms 10520 KB Output is correct