Submission #923994

# Submission time Handle Problem Language Result Execution time Memory
923994 2024-02-08T08:12:35 Z NintsiChkhaidze A Huge Tower (CEOI10_tower) C++17
90 / 100
26 ms 7516 KB
#include <bits/stdc++.h>
#define ll long long
#define s second
#define f first
#define pb push_back
#define pii pair <int,int>
#define left (h<<1),l,(l + r)/2
#define right ((h<<1)|1),(l + r)/2 + 1,r
#define int ll
using namespace std;

const int N = 2e5 + 3,mod = 1e9 + 9;

int a[N],c[N];
signed main(){
	ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);

    int n,D;
    cin>>n>>D;

    for (int i = 1; i <= n; i++)
        cin >> a[i];

    sort(a+1,a+n+1);
    int r = n + 1;

    for (int i = n; i >= 1; i--){
        while (r - 1 >= 1 && a[i] <= a[r - 1] + D){
            --r;
        }
        c[i] = max(0LL,i - r);
    }

    int ans=1;
    for (int i= 1; i <= n; i++){
        ans = ans * (c[i] + 1) % mod;
    }
    cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 2512 KB Output is correct
2 Correct 7 ms 2516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 18 ms 7516 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 7508 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -