Submission #856619

#TimeUsernameProblemLanguageResultExecution timeMemory
856619HanavMA Huge Tower (CEOI10_tower)C++17
100 / 100
215 ms10504 KiB
// Source: https://usaco.guide/general/io #include <bits/stdc++.h> using namespace std; typedef long long ll; ll mod = 1e9 + 9; int main() { ll n, d; cin >> n >> d; vector <ll> blocks(n); for (int i=0;i<n;i++){ cin >> blocks[i]; } int left = 0; int right = 0; ll ans = 1; sort(begin(blocks),end(blocks)); for (int i=1;i<n;i++){ ll constant = blocks[i] - d; while (left < n){ if (blocks[left] < constant){ left++; } else{ break; } } right ++; // cout <<i <<" " << left << " " << right << endl; if (left != right){ ans = ans * (right - left + 1); ans = ans % mod; } } cout << ans % mod; }
#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...