Submission #989972

#TimeUsernameProblemLanguageResultExecution timeMemory
989972IdanRosenA Huge Tower (CEOI10_tower)C++98
100 / 100
108 ms10688 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<ll, ll> pll; typedef pair<ld, ld> pld; #define MOD ((ll) 1e9 + 9) int main() { ios_base::sync_with_stdio(false); cout.tie(nullptr); cin.tie(nullptr); ll n, d; cin >> n >> d; vector<ll> arr(n); for (auto &ref: arr) cin >> ref; std::sort(arr.begin(), arr.end()); ll ans = 1; for (int i = 1; i < n; i++) { ll curr_width = arr[i]; ll start = 0; ll end = i; while (start < end) { ll mid = start + (end - start) / 2; if (arr[mid] + d < curr_width) start = mid + 1; else end = mid; } ans = ans * ((1 + i - start) % MOD); ans %= MOD; } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...