Submission #394534

# Submission time Handle Problem Language Result Execution time Memory
394534 2021-04-26T19:50:51 Z __SIGSEGV__ A Huge Tower (CEOI10_tower) C++17
100 / 100
136 ms 5444 KB
#include <bits/stdc++.h>

using namespace std;

constexpr long long mod = 1e9 + 9;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, d;
  cin >> n >> d;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  long long answer = 1;
  int l = 0;
  for (int r = 1; r < n; r++) {
    while (l < r && a[r] - a[l] > d) {
      ++l;
    }
    answer = answer * (r - l + 1) % mod;
  }
  cout << answer << '\n';
  return 0;
}
# 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 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 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 1 ms 320 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 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 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 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 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 972 KB Output is correct
2 Correct 10 ms 972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 3344 KB Output is correct
2 Correct 52 ms 3400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 108 ms 4876 KB Output is correct
2 Correct 136 ms 5444 KB Output is correct