Submission #1127780

#TimeUsernameProblemLanguageResultExecution timeMemory
1127780marcus06A Huge Tower (CEOI10_tower)C++17
100 / 100
113 ms5188 KiB
#include <bits/stdc++.h> using namespace std; using lli = int64_t; //replace with your directory #ifdef LOCAL #include <C:/Coding/CP/templates/content/debug/debug.h> #else #define debug(...) #endif const int mod = 1000000009; void solve() { int n, d; cin >> n >> d; vector <int> a(n + 1); for (int i = 1; i <= n; ++i) { cin >> a[i]; } sort(a.begin(), a.end()); vector <int> dp(n + 1, 0); dp[0] = 1; for (int i = 1, j = 1; i <= n; ++i) { while (j < i && a[j] + d < a[i]) j++; dp[i] = 1LL * dp[i - 1] * (i - j + 1) % mod; } cout << dp[n] << '\n'; } int main() { std::cin.tie(0)->sync_with_stdio(0); #ifdef LOCAL auto begin = std::chrono::high_resolution_clock::now(); #endif int tt = 1; while (tt--) { solve(); } #ifdef LOCAL auto end = std::chrono::high_resolution_clock::now(); auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin); std::cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; #endif return 0; }
#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...