Submission #417825

# Submission time Handle Problem Language Result Execution time Memory
417825 2021-06-04T11:03:42 Z Nghes A Huge Tower (CEOI10_tower) C++14
100 / 100
146 ms 10556 KB
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#define E '\n'
#define name "main"
#define int ll
const int base = 1e9+9;
const int N = 1e6;
int a[N+13];
int n,k;
signed main(){
    ios::sync_with_stdio(0); cin . tie(0);
    //freopen(name".INP","r",stdin);  freopen(name".OUT","w",stdout);
    cin >> n  >> k;
    for (int i=1; i <= n ; ++i) cin >>a[i];
    sort(a+1,a+1+n,greater<int>());
    int res = 1;
    for (int r =1,l=1; r <= n ; ++r){
        while (a[l] - a[r] > k) ++l;
        res = res * (r-l+1) % base;
    }
    cout << res << E;





}

# 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 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 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 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 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 716 KB Output is correct
2 Correct 11 ms 1100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 2204 KB Output is correct
2 Correct 57 ms 4608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 127 ms 5108 KB Output is correct
2 Correct 146 ms 10556 KB Output is correct