제출 #1128933

#제출 시각아이디문제언어결과실행 시간메모리
1128933anonymous321A Huge Tower (CEOI10_tower)C++20
100 / 100
107 ms10052 KiB
// https://oj.uz/problem/view/CEOI10_tower #include <bits/stdc++.h> using namespace std; typedef long long ll; const ll M = 1e9 + 9; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; ll d; cin >> n >> d; vector<ll> v (n); for (int i = 0; i < n; i++) { cin >> v[i]; } sort(v.begin(), v.end()); vector<ll> comp (n, 0); int cur = 1; for (int i = 0; i < n; i++) { int cnt = 0; cur = max(cur, i + 1); while (cur < n && v[cur] <= v[i] + d) { cnt++; cur++; } if (i > 0) comp[i] = max(0LL, comp[i-1] - 1); comp[i] += cnt; } ll sol = 1; for (int i = n-2; i >= 0; i--) { ll x = 1 + comp[i]; x = x % M; sol = (sol * x) % M; } cout << sol << "\n"; 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...