Submission #458156

# Submission time Handle Problem Language Result Execution time Memory
458156 2021-08-08T01:53:39 Z JovanB A Huge Tower (CEOI10_tower) C++17
100 / 100
143 ms 8800 KB
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
 
const int MOD = 1000000009;
 
int add(int a, int b){ a += b; if(a >= MOD) a -= MOD; return a; }
int mul(int a, int b){ return (1LL*a*b)%MOD; }
 
const int MAXN = 1000000;
 
int a[MAXN+5];
 
int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;
 
    int n, d;
    cin >> n >> d;
    for(int i=1; i<=n; i++){
        cin >> a[i];
    }
    sort(a+1, a+1+n);
    int res = 1;
    int j = 1;
    for(int i=1; i<=n; i++){
        while(a[i] - a[j] > d) j++;
        res = mul(res, i-j+1);
    }
    cout << res << "\n";
    return 0;
}
# 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 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 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 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 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 380 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 332 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 3 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 948 KB Output is correct
2 Correct 14 ms 1016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 67 ms 3660 KB Output is correct
2 Correct 57 ms 3736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 124 ms 8800 KB Output is correct
2 Correct 143 ms 8136 KB Output is correct