Submission #930475

# Submission time Handle Problem Language Result Execution time Memory
930475 2024-02-20T01:36:16 Z Darren0724 A Huge Tower (CEOI10_tower) C++17
100 / 100
92 ms 11368 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define LCBorz ios_base::sync_with_stdio(false); cin.tie(0);
#define all(x) x.begin(), x.end()
const int N=200005;
const int INF=1e18;
const int mod=1e9+9;
int32_t main() {
    LCBorz;
    int n,k;cin>>n>>k;
    vector<int> v(n+1);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    v[n]=INF;
    sort(all(v));
    int ans=1;
    for(int i=n-1,j=n-1;i>=0;i--){
        while(j>=i&&v[j]>v[i]+k)j--;
        ans=ans*(j-i+1)%mod;
    }
    cout<<ans<<endl;
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1116 KB Output is correct
2 Correct 7 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 4688 KB Output is correct
2 Correct 38 ms 4692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 79 ms 11368 KB Output is correct
2 Correct 92 ms 10768 KB Output is correct