Submission #868156

#TimeUsernameProblemLanguageResultExecution timeMemory
868156overwatch9A Huge Tower (CEOI10_tower)C++17
20 / 100
1066 ms54908 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; using ll = long long; const int mod = 1e9 + 9; vector <ll> dp, nums; int n, d; ll solve(int i) { if (i == 0) return 1; if (dp[i] != -1) return dp[i]; ll ans = solve(i-1); for (int j = i-1, x = 1; j > 0; j--, x++) { if (j > 0 && nums[j] + d < nums[i]) break; ans += solve(j) * x; ans %= mod; } dp[i] = ans; return ans; } int main() { cin >> n >> d; dp.resize(n+1, -1); nums.resize(n+1); 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...