Submission #393554

#TimeUsernameProblemLanguageResultExecution timeMemory
393554aaronhmaA Huge Tower (CEOI10_tower)C++17
100 / 100
132 ms10612 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vll; #define all(x) begin(x), end(x) #define sz(x) (int)x.size() #define FORE(i, a, b) for (ll i = a; i < b; i++) const int MOD = 1e9 + 9; // 19^9 + 9 for "CEOI 2010 - A Huge Tower" // INPUT template <class T> void read(T &x) { cin >> x; } template <class Arg, class... Args> void read(Arg &first, Args &...rest); template <class T> void read(vector<T> &a); template <class Arg, class... Args> void read(Arg &first, Args &...rest) { read(first); read(rest...); } template <class T> void read(vector<T> &a) { FORE(i, 0, sz(a)) read(a[i]); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n, d, ans = 1, j = 0; read(n, d); vll arr(n); read(arr); sort(all(arr)); FORE(i, 0, n) { while (j < n && arr[j] - arr[i] <= d) j++; ans = (ans * (j - i)) % MOD; } cout << ans << "\n"; 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...