Submission #1011056

#TimeUsernameProblemLanguageResultExecution timeMemory
1011056Rishabh_GalaA Huge Tower (CEOI10_tower)C++17
100 / 100
196 ms17580 KiB
#include<vector> #include<iostream> #include<queue> #include<algorithm> #include<fstream> using namespace std; int main(){ long long mo = 1000000009; long long n, d; cin >> n >> d; vector<long long> lst; for (long long i = 0; i < n; i++){ long long temp; cin >> temp; lst.push_back(temp); } sort(lst.begin(), lst.end()); vector<long long> left(n, 0); long long r = n-1; long long l = n-1; while (r >= 0 && l >= 0){ if (lst[l] + d >= lst[r]){ left[r] = l; l--; } else { r--; if (r >= 0){ left[r] = l+1; } } } long long ans = 1; for (long long i = 0; i < n; i++){ ans = ans*(i - left[i] + 1) % mo; } cout << ans << endl; 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...