Submission #346591

#TimeUsernameProblemLanguageResultExecution timeMemory
346591Ca7Ac1A Huge Tower (CEOI10_tower)C++17
100 / 100
138 ms15468 KiB
#include <iostream> #include <algorithm> #include <vector> #include <set> #include <map> #define ll signed long long using namespace std; const ll MOD = 1e9 + 9; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); //freopen("tower.in", "r", stdin); ll N; ll D; cin >> N >> D; vector<ll> blocks(N, 0); for (ll i = 0; i < N; i++) { cin >> blocks[i]; } sort(blocks.begin(), blocks.end(), greater<ll>()); vector<ll> place(N, 1); ll j = 0; for (ll i = 0; i < N; i++) { while (j < N && blocks[i] - blocks[j] <= D) { j++; } place[i] = j - i; } ll sol = 1; for (ll i = N - 1; i >= 0; i--) { sol *= place[i] % MOD; sol %= MOD; } cout << (sol % 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...