Submission #879251

# Submission time Handle Problem Language Result Execution time Memory
879251 2023-11-27T04:14:52 Z theghostking A Huge Tower (CEOI10_tower) C++17
100 / 100
234 ms 16192 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main() {
    int n,d;
    cin >> n >> d;
    int arr[n];
    for (int i = 0; i<n; i++){
        cin >> arr[i];
    }
    sort(arr,arr+n);
    int nxt[n];
    for (int i = 0; i<n; i++){
        auto it = upper_bound(arr,arr+n,arr[i]+d);
        nxt[i] = (it-arr)-i;
    }
    const int MOD = 1e9+9;
    int ans = 1;
    for (int i = 0; i<n; i++){
        //cout << nxt[i] << " ";
        ans *= nxt[i];
        ans %= MOD;
    }
    //cout << "\n\n";
    cout << ans;
    return 0;
}
# 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 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 348 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 348 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 348 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 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 428 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 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 1620 KB Output is correct
2 Correct 18 ms 1624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 98 ms 6772 KB Output is correct
2 Correct 92 ms 6716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 220 ms 16192 KB Output is correct
2 Correct 234 ms 15368 KB Output is correct