Submission #480394

#TimeUsernameProblemLanguageResultExecution timeMemory
480394nehasaneA Huge Tower (CEOI10_tower)C++14
15 / 100
306 ms2704 KiB
#include <bits/stdc++.h> using namespace std; const int mod = 1000000009; long long factorial(int s){ long long ans = 1; for (int i = s; i >= 1; i--) ans *= i; return ans % mod; } int main() { int n, d; cin >> n >> d; vector <int> blocks(n); for (int i = 0; i < n; i++) cin >> blocks[i]; sort(begin(blocks), end(blocks)); long long ans = 1; int l = 0, r = 0; while (r < n){ if (blocks[l] + d < blocks[r]){ ans = (ans * factorial(r-l)) % mod; if (blocks[r] + d >= blocks[r+1]) l = r-1; else l = r; } r++; } cout << ans << '\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...