Submission #393553

#TimeUsernameProblemLanguageResultExecution timeMemory
393553aaronhmaA Huge Tower (CEOI10_tower)C++17
85 / 100
1091 ms5068 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef string str; typedef vector<int> vi; typedef vector<bool> vb; typedef vector<ll> vll; typedef vector<char> vc; typedef vector<str> vstr; typedef vector<vi> vvi; typedef pair<int, int> pii; typedef vector<pii> vpii; #define f first #define s second #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) #define PB push_back #define sz(x) (int)x.size() #define rtn return #define rsz resize #define ins insert #define ft front() #define bk back() #define LB lower_bound #define UB upper_bound #define BINS binary_search #define READ(x) ifstream cin(x ".in"); #define OUT(x) ofstream cout(x ".out"); #define IT(x) for (auto it = begin(x); it != end(x); it++) #define RIT(x) for (auto it = rbegin(x); it != rend(x); it++) #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" const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; // Returns ceil(a / b) (b != 0) int ceildiv(int a, int b) { rtn a / b + !(a < 0 || a % b == 0); } // 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(complex<T> &x); template <class T1, class T2> void read(pair<T1, T2> &p); template <class T> void read(vector<T> &a); template <class T, size_t SZ> void read(array<T, SZ> &a); template <class Arg, class... Args> void read(Arg &first, Args &...rest) { read(first); read(rest...); } template <class T> void read(complex<T> &x) { T a, b; read(a, b); x = cd(a, b); } template <class T1, class T2> void read(pair<T1, T2> &p) { read(p.f, p.s); } template <class T> void read(vector<T> &a) { FORE(i, 0, sz(a)) read(a[i]); } template <class T> void read(vector<T> &a, int n) { FORE(i, 0, n) read(a[i]); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n, d, ans = 1; read(n, d); vll arr(n); read(arr); sort(all(arr)); FORE(i, 0, n) { ll j = i; 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...