Submission #762710

#TimeUsernameProblemLanguageResultExecution timeMemory
762710lalig777A Huge Tower (CEOI10_tower)C++14
100 / 100
222 ms7604 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long long int ll; int main (){ int n, d; cin>>n>>d; vector<int>v(n); for (int i=0; i<n; i++) cin>>v[i]; sort(v.begin(), v.end()); vector<int>dp(n); vector<int>b(n); for (int i=1; i<n; i++){ b[i]=b[i-1]+1; for (int j=i-b[i]; j<i; j++){ if (v[i]>v[j]+d) b[i]--; else break; } }dp[0]=1; int mod = 1e9+9; for (int i=1; i<n; i++) dp[i]=(dp[i-1]*1ll*(b[i]+1))%mod; 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...