Submission #762681

#TimeUsernameProblemLanguageResultExecution timeMemory
762681a_aguiloA Huge Tower (CEOI10_tower)C++14
30 / 100
81 ms14868 KiB
#include<bits/stdc++.h> using namespace std; int N, D; 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; } long long dp[N]; dp[0] = 1; for(int i = 1; i < N; ++i){ dp[i] = dp[i-1]*(b[i] + 1 - (N - i)); //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...