Submission #762686

#TimeUsernameProblemLanguageResultExecution timeMemory
762686hfoliacotsA Huge Tower (CEOI10_tower)C++14
35 / 100
203 ms7584 KiB
#include <bits/stdc++.h> using namespace std; void print(vector<int>& v) { for (int i = 0; i < (int)v.size(); i++) cout << v[i] << ' '; cout << endl; } int 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...