Submission #365065

# Submission time Handle Problem Language Result Execution time Memory
365065 2021-02-10T20:38:14 Z horsefeedapples A Huge Tower (CEOI10_tower) C++11
100 / 100
322 ms 10732 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const int MOD = 1e9+9;

int main() {
  ll n, d;
  cin>>n>>d;
  ll arr[n];
  for(ll i=0; i<n; i++){
    cin>>arr[i];
  }
  sort(arr, arr+n);
  ll l = 0, r = 0;
  ll sol = 1;
  for(; l<n; l++){
    while(arr[l]+d>=arr[r+1] && r<n-1){
      r++;
    }
    ll dist = r-l+1;
    sol = (sol*dist)%MOD;
  }
  cout<<(sol%MOD);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1004 KB Output is correct
2 Correct 26 ms 1260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 131 ms 2520 KB Output is correct
2 Correct 124 ms 4716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 322 ms 5488 KB Output is correct
2 Correct 313 ms 10732 KB Output is correct