Submission #762689

#TimeUsernameProblemLanguageResultExecution timeMemory
762689a_aguiloA Huge Tower (CEOI10_tower)C++14
100 / 100
101 ms14748 KiB
#include<bits/stdc++.h> using namespace std; int N, D; int MOD = 1e9 + 9; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> N >> D; long long a[N]; long long b[N]; for(int i = 0; i < N; ++i) cin >> a[i]; sort(a, a + N); int left = 0; int right = 0; for(int i = 0; i < N; ++i){ while(right < N and a[right] >= a[i]-D)right++; while(a[left] < a[i]-D) left++; b[i] = (right-left)%MOD; } long long dp[N]; dp[0] = 1; for(int i = 1; i < N; ++i){ dp[i] = (dp[i-1]*(b[i] + 1 - (N - i)))%MOD; //cout << b[i] << " " << dp[i] << endl; } cout << dp[N-1] << endl; 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...