Submission #365061

# Submission time Handle Problem Language Result Execution time Memory
365061 2021-02-10T20:36:27 Z horsefeedapples A Huge Tower (CEOI10_tower) C++11
20 / 100
306 ms 5228 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const int MOD = 1e9+9;

ll factorial(ll n){
  if(n==0) return 1;
  return n*factorial(n-1);
}

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);
  map<ll, ll> m; // value, number of values 
  ll l = 0, r = 0;
  for(; l<n; l++){
    if(arr[l]+d<arr[r]){
      l = r;
    }
    while(arr[l]+d>=arr[r] && r<n){
      m[l]=r-l+1;
      r++;
    }
  }
  ll ans = 1;
  for(auto u: m){
    ans*=factorial(u.second);
  }
  cout<<(ans%MOD);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 396 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 720 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 132 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 306 ms 5228 KB Output isn't correct
2 Halted 0 ms 0 KB -