Submission #462239

# Submission time Handle Problem Language Result Execution time Memory
462239 2021-08-10T08:55:01 Z AlexLuchianov A Huge Tower (CEOI10_tower) C++14
100 / 100
141 ms 9860 KB
#include <iostream>
#include <vector>
#include <algorithm>

using ll = long long;

int const modulo = 1000000009;

int main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);

  int n, d;
  std::cin >> n >> d;
  std::vector<int> v;
  for(int i = 1; i <= n; i++) {
    int aux;
    std::cin >> aux;
    v.push_back(aux);
  }
  std::sort(v.begin(), v.end());
  int ptr = v.size() - 1;
  int result = 1;
  for(int i = v.size() - 2; 0 <= i; i--) {
    while(v[i] + d < v[ptr])
      ptr--;
    result = 1LL * result * (ptr - i + 1) % modulo;
  }
  std::cout << result;
  return 0;
}
# 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 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 312 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 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 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 1100 KB Output is correct
2 Correct 12 ms 1104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 3824 KB Output is correct
2 Correct 63 ms 3776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 124 ms 9860 KB Output is correct
2 Correct 141 ms 9400 KB Output is correct