Submission #762691

#TimeUsernameProblemLanguageResultExecution timeMemory
762691hfoliacotsA Huge Tower (CEOI10_tower)C++14
100 / 100
236 ms14748 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int n, d; int inf = 1e9+9; cin >> n >> d; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; sort(a.begin(), a.end()); vector<int> b(n); int j = n-2; int cont = 1; for (int i = n-1; i > -1; i--) { while (j >= 0 && a[i] <= a[j]+d) { j--; cont++; } cont--; b[i] = cont % inf; } vector<int> dp(n); dp[0] = 1; for (int i = 1; i < n; i++) { dp[i] = (dp[i-1] * (b[i] + 1)) % inf; } //print(dp); cout << dp[n-1] << endl; }
#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...