Submission #540729

# Submission time Handle Problem Language Result Execution time Memory
540729 2022-03-21T15:00:56 Z jakubd A Huge Tower (CEOI10_tower) C++17
100 / 100
115 ms 10540 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

signed main() {
  ios_base::sync_with_stdio(false); cin.tie(0);

  const int mod = 1e9+9;
  int n, d; cin >> n >> d;
  vector<int> a(n); for (auto &x : a) cin >> x;
  sort(a.begin(), a.end());

  int ans = 1;
  for (int l = 0, r = 0; l < n; l++) {
    while (r + 1 < n && a[r + 1] - a[l] <= d) r++;
    ans = ans * (r - l + 1) % mod;
  }
  cout << ans << "\n";

  return 0;
};
# 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 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 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 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 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 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 724 KB Output is correct
2 Correct 11 ms 1096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 2260 KB Output is correct
2 Correct 51 ms 4692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 101 ms 5076 KB Output is correct
2 Correct 115 ms 10540 KB Output is correct