Submission #850877

#TimeUsernameProblemLanguageResultExecution timeMemory
850877tvladm2009A Huge Tower (CEOI10_tower)C++17
100 / 100
93 ms11464 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int M = (int) 1e9 + 9; int n; int d; int mul(int a, int b) { return a * (ll)b % M; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> d; vector<int> v; for (int i = 1; i <= n; i++) { int x; cin >> x; v.push_back(x); } sort(v.begin(), v.end()); int j = (int) v.size() - 1; int ret = 1; for (int i = (int) v.size() - 2; i >= 0; i--) { while (v[i] + d < v[j]) { j--; } ret = mul(ret, j - i + 1); } cout << ret << "\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...