Submission #932896

#TimeUsernameProblemLanguageResultExecution timeMemory
932896KavelmydexA Huge Tower (CEOI10_tower)C++17
90 / 100
1092 ms11280 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 j = i-1; while(j >= 0 && a[j]-a[i] <= k) j--; ans *= (i-j); 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...