Submission #990966

# Submission time Handle Problem Language Result Execution time Memory
990966 2024-05-31T22:32:26 Z i_liek_cheezits A Huge Tower (CEOI10_tower) C++17
100 / 100
82 ms 2652 KB
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1e9+9;
int main() {
  fastIO
  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());
  int r = 0;  int ans = 1;
  for (int l = 0; l < n; l++) {
   	while (r<n-1 && a[r+1]-a[l] <= d) r++;
    int count = r-l+1;
    ans = (ans * 1LL * count) % MOD;
  }
  cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 604 KB Output is correct
2 Correct 6 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 1372 KB Output is correct
2 Correct 34 ms 1368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 2652 KB Output is correct
2 Correct 82 ms 2648 KB Output is correct