Submission #741046

#TimeUsernameProblemLanguageResultExecution timeMemory
741046mannshah1211A Huge Tower (CEOI10_tower)C++14
100 / 100
285 ms15948 KiB
// Master by November 2023 #include <bits/stdc++.h> using namespace std; #define int long long #define all(x) x.begin(), x.end() #define f first #define s second #define pb push_back #define forn(i, n) for (int i = 0; i < n; i++) int32_t main() { int n, d; cin >> n >> d; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(all(a)); vector<int> b(n); int answer = 1; for (int i = 0; i < n; i++) { int lo = 0, hi = i, ind = -1; while (lo <= hi) { int mid = (lo + hi) >> 1; if (a[mid] >= a[i] - d) { ind = mid; hi = mid - 1; } else { lo = mid + 1; } } answer *= (i - ind + 1); answer %= (int) (1e9 + 9); } cout << answer << '\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...