#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 time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
716 KB |
Output is correct |
2 |
Execution timed out |
1091 ms |
1100 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
524 ms |
2252 KB |
Output is correct |
2 |
Execution timed out |
1077 ms |
4676 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1085 ms |
5068 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |