Submission #868389

#TimeUsernameProblemLanguageResultExecution timeMemory
868389overwatch9A Huge Tower (CEOI10_tower)C++17
100 / 100
266 ms39824 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; using ll = long long; const int mod = 1e9 + 9; vector <ll> dp, nums, perm; int n, d; ll solve(int i) { if (i <= 0) return 1; if (dp[i] != -1) return dp[i]; int l = lower_bound(nums.begin() + 1, nums.end(), nums[i] - d) - nums.begin(); ll ans = solve(i-1) * (i - l + 1); ans %= mod; dp[i] = ans; return ans; } int main() { cin >> n >> d; dp.resize(n+1, -1); nums.resize(n+1); perm.resize(n+1); perm[1] = 1; for (int i = 2; i <= n; i++) perm[i] = (perm[i-1] * i) % mod; for (int i = 1; i <= n; i++) cin >> nums[i]; sort(nums.begin(), nums.end()); cout << solve(n) << '\n'; }
#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...