Submission #553391

#TimeUsernameProblemLanguageResultExecution timeMemory
553391Hona_NguyenA Huge Tower (CEOI10_tower)C++17
100 / 100
135 ms11160 KiB
#include<bits/stdc++.h> #define prob "C" using namespace std; const int maxn = 1e5; const int MOD = 1e9 + 9; int main(){ // freopen(prob".inp","r",stdin); // freopen(prob".out","w",stdout); ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); int n; long long d; cin >> n >> d; vector<long long> a(n); for(int i=0;i<n;i++) cin >> a[i]; sort(a.begin(),a.end()); long long res = 1; for(int i=0;i<n;i++){ int L = 0, R = i-1, choose = -1; while(L <= R){ int mid = (L + R) >> 1; if(a[mid] + d >= a[i]){ choose = mid; R = mid - 1; } else{ L = mid + 1; } } if(choose == -1) continue; res = res * 1ll * (i - choose + 1) % MOD; // cout << i << " " << choose << " " << endl; } cout << res; }
#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...