Submission #768788

# Submission time Handle Problem Language Result Execution time Memory
768788 2023-06-28T15:35:37 Z orcslop A Huge Tower (CEOI10_tower) C++17
100 / 100
99 ms 14980 KB
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)(x).size() 

const int MOD = 1e9 + 9; 

int n, d; 
vector<int> blocks, v;  

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin >> n >> d; 
    for(int i = 0; i < n; i++){
        int a; cin >> a; 
        blocks.push_back(a); 
    }
    sort(blocks.begin(), blocks.end()); 
    int index = 0; 
    for(int i = 0; i < n; i++){
        while(index < n && blocks[index] + d < blocks[i]) index++; 
        v.push_back(i - index); 
    }
    long long ans = 1; 
    for(auto x : v) ans = ans * (x + 1) % MOD; 
    cout << ans; 
    return 0; 
}
# 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 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 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 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 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 1 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 324 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 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1368 KB Output is correct
2 Correct 10 ms 1368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 5228 KB Output is correct
2 Correct 37 ms 5216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 87 ms 14980 KB Output is correct
2 Correct 99 ms 14360 KB Output is correct