Submission #535147

# Submission time Handle Problem Language Result Execution time Memory
535147 2022-03-09T13:58:38 Z andecaandeci A Huge Tower (CEOI10_tower) C++17
100 / 100
299 ms 8744 KB
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 9;
int main(){
    int n,d;
    cin >> n >> d;
    int arr[n+5];
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }
    sort(arr,arr+n);
    int r = 0, sol = 1;
  for (int l = 0; l < n; l++) {
    while (r < n - 1 && arr[r + 1] - arr[l] <= d) r++;
    int dist = r - l + 1; 
    sol = (sol * 1LL * dist) % MOD;
  }
  cout << sol << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 284 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 288 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 292 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 288 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 288 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 2 ms 284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 948 KB Output is correct
2 Correct 23 ms 948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 154 ms 3688 KB Output is correct
2 Correct 121 ms 3668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 299 ms 8744 KB Output is correct
2 Correct 271 ms 8184 KB Output is correct