Submission #932900

#TimeUsernameProblemLanguageResultExecution timeMemory
932900KavelmydexA Huge Tower (CEOI10_tower)C++17
100 / 100
119 ms10532 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pi pair<int,int> #define vi vector<int> #define rep(i,x,n) for(int i=x; i<n; ++i) #define For(i,n) rep(i,0,n) #define pb push_back // #define f first #define s second #define endl "\n" #define sp ' ' #define sz size() #define all(x) (x).begin(),(x).end() const int N = 100, OO = 1e18, mod = 1e9+9, mx = 1e6+10; void tr(int a, int b){cout << a << sp << b << endl;} void cmx(int &a, int b){a = max(a,b);} void cmn(int &a, int b){a = min(a,b);} int n,k; int a[N], vis[N], ans; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> k; vi a(n); for(int &i: a) cin >> i; sort(a.rbegin(), a.rend()); ans = 1; for(int i=1; i<n; ++i){ int l = -1, r = i; while(r > l+1){ int m = (l+r)/2; if(a[m]-a[i] <= k) r = m; else l = m; } ans *= (i-l); ans %= mod; } cout << ans << 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...