Submission #654306

#TimeUsernameProblemLanguageResultExecution timeMemory
654306megargayuA Huge Tower (CEOI10_tower)C++17
25 / 100
16 ms848 KiB
// https://oj.uz/problem/view/CEOI10_tower #include <bits/stdc++.h> using namespace std; #define ll long long #define MOD ((ll)1e9 + 9) #define MAX_N 70 vector<int> a(MAX_N); // TODO int main() { int N, D; cin >> N >> D; for (int i = 0; i < N; ++i) cin >> a[i]; sort(a.begin(), a.begin() + N); // products of factorials of all valid "subproblems" ll ans = 1; int i = 0, j = 0; while (i < N && j < N) { if (a[j] - a[i] <= D) { ans = (ans % MOD) * ((j - i + 1) % MOD); ans %= MOD; } if (j < N - 1 && a[j + 1] - a[i] <= D) ++j; else if (j < N - 1 && a[j + 1] - a[j] <= D) { i = j; } else i = ++j; } cout << ans << '\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...