Submission #498634

#TimeUsernameProblemLanguageResultExecution timeMemory
498634aadit_ambadkarA Huge Tower (CEOI10_tower)C++11
30 / 100
112 ms13660 KiB
/* This code belongs to Aadit Ambadkar Date: 2021-12-25 16:34:50 Problem: tower */ #include <bits/stdc++.h> using namespace::std; typedef long long ll; #define F0R(i, n) for (int i = 0; i < n; i++) #define R0F(i, n) for (int i = n-1; i >= 0; i--) #define FOR(i, a, n) for (int i = a; i < n; i++) #define pb push_back #define fastio ios::sync_with_stdio(0); cin.tie(0) #define MOD 1000000007 #define FF first #define SS second int main() { fastio; int n, d; cin >> n >> d; vector<int> v; F0R(i, n) { int x; cin >> x; v.pb(x); } sort(v.begin(), v.end()); vector<ll> dp(n, 0); dp[0]=1; int p = 0; FOR(i, 1, n) { while (v[i]-v[p]>d) p++; dp[i]=dp[i-1]*(i-p+1); dp[i]%=MOD; } cout << dp[n-1] << "\n"; }
#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...