Submission #923864

#TimeUsernameProblemLanguageResultExecution timeMemory
923864hqminhuwuA Huge Tower (CEOI10_tower)C++14
100 / 100
92 ms12664 KiB
#include <bits/stdc++.h> #define forr(_a,_b,_c) for(_a = (_b); _a <= (_c); ++_a) #define ford(_a,_b,_c) for(_a = (_b) + 1; _a --> (_c);) #define forf(_a,_b,_c) for(_a = (_b); _a < (_c); ++_a) #define st first #define nd second #define ll long long #define ull unsigned long long #define pii pair <int,int> #define pll pair <ll,ll> #define piii pair <int,pii> #define vi vector <int> #define pb push_back #define mp make_pair #define all(x) begin(x),end(x) #define file "test" using namespace std; const int N = 2e6 + 5; const ll oo = 1e9; const ll mod = 1e9 + 9; ll n, i, a[N], d, ans = 1; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); #ifdef hqm freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout); #endif cin >> n >> d; forr (i, 1, n) cin >> a[i]; sort(a + 1, a + 1 + n, greater<int>()); ll r = 1; a[n + 1] = -2 * oo - 1; forr (i, 1, n){ r = max (r, i); while (a[i] - a[r + 1] <= d) r++; ans = (ans * (r - i + 1)) % mod; // cout << a[i] << " " << r << "\n"; } cout << ans; 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...