Submission #1011056

# Submission time Handle Problem Language Result Execution time Memory
1011056 2024-06-29T18:02:59 Z Rishabh_Gala A Huge Tower (CEOI10_tower) C++17
100 / 100
196 ms 17580 KB
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
#include<fstream>
using namespace std;
int main(){
    long long mo = 1000000009;
    long long n, d;
    cin >> n >> d;
    vector<long long> lst;
    for (long long i = 0; i < n; i++){
        long long temp;
        cin >> temp;
        lst.push_back(temp);
    }
    sort(lst.begin(), lst.end());
    vector<long long> left(n, 0);
    long long r = n-1;
    long long l = n-1;
    while (r >= 0 && l >= 0){
        if (lst[l] + d >= lst[r]){
            left[r] = l;
            l--;
        } else {
            r--;
            if (r >= 0){
                left[r] = l+1;
            }
        }
    }
    long long ans = 1;
    for (long long i = 0; i < n; i++){
        ans = ans*(i - left[i] + 1) % mo;
    }
    cout << ans << endl;
    return 0;
}
# 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 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 344 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 344 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 1 ms 436 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 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 344 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 5 ms 704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 1748 KB Output is correct
2 Correct 17 ms 1748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 88 ms 6772 KB Output is correct
2 Correct 103 ms 6856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 182 ms 17456 KB Output is correct
2 Correct 196 ms 17580 KB Output is correct