Submission #755983

# Submission time Handle Problem Language Result Execution time Memory
755983 2023-06-10T19:07:43 Z vjudge1 A Huge Tower (CEOI10_tower) C++17
100 / 100
119 ms 8108 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "C:\GCC\debug.h"
#else
#define debug(...) void(42)
#endif

const int md = 1000000009;

int add(int &a, int b) {
  a += b;
  if (a > md) {
    a -= md;
  }
  return a;
}

int mult(int a, int b) {
  return (int) ((long long) a * b % md);
}


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  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 res = 1;
  int low = 0;
  for (int high = 0; high < n; high++) {
    while (a[low] + d < a[high]) {
      ++low;
    }
    debug(high, high, low);
    res = mult(res, high - low + 1);
  }
  cout << res << '\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 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 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 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 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 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 468 KB Output is correct
2 Correct 10 ms 904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 1236 KB Output is correct
2 Correct 43 ms 3776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 90 ms 2644 KB Output is correct
2 Correct 119 ms 8108 KB Output is correct