Submission #726414

# Submission time Handle Problem Language Result Execution time Memory
726414 2023-04-18T21:36:49 Z professionalACer A Huge Tower (CEOI10_tower) C++17
100 / 100
273 ms 11140 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 1e9 + 9;
signed main() {
  int N, D;
  cin >> N >> D;
  int A[N];
  for (auto &x : A) cin >> x;
  sort(A, A + N);
  int p = 0, ans = 1;
  for (int i = 0; i < N; i++) {
    while (p < N - 1 && A[p + 1] - A[i] <= D) p++;
    int d = p - i + 1;
    ans = (ans * d) % mod;
  }
  cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1184 KB Output is correct
2 Correct 22 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 122 ms 4668 KB Output is correct
2 Correct 124 ms 4676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 256 ms 11140 KB Output is correct
2 Correct 273 ms 10612 KB Output is correct