Submission #388551

# Submission time Handle Problem Language Result Execution time Memory
388551 2021-04-12T04:55:23 Z shawon_majid A Huge Tower (CEOI10_tower) C++14
100 / 100
317 ms 2712 KB
//Bismillahir Rahman-ir Rahim
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << " : " << x << endl;
#define all(c) c.begin(), c.end()
#define F first
#define S second
typedef unsigned long long ull;
typedef long long ll;

const int mod = 1e9+9;

int main() {

    int n, d;
    cin >> n >> d;

    vector<int> ara(n);
    for(int i = 0; i < n; i++){
        cin >> ara[i];
    }

    sort(all(ara));
    ll ans = 1;
    for(int i = 1, j = 0; i < n; i++){
        while(j < n and ara[j]+d < ara[i]) {
            j++;
        }
        ans = ((ans%mod)*((i-j+1)%mod))%mod;
    }

    cout << ans << endl;
        
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 500 KB Output is correct
2 Correct 27 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 142 ms 1272 KB Output is correct
2 Correct 130 ms 1276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 296 ms 2712 KB Output is correct
2 Correct 317 ms 2708 KB Output is correct