This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
#define F0R(i, a, b) for (int i = (a); i < (b); i++)
#define FOR(i, a) F0R(i, 0, a)
#define f first
#define s second
int cx[] = {0, 1, 0, -1};
int cy[] = {1, 0, -1, 0};
const ll INF = 1e9 + 9;
bool cpr(ll a, ll b)
{
return {a > b};
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n, diff;
cin >> n >> diff;
vector<ll> nums(n);
FOR(i, n) cin >> nums[i];
sort(nums.begin(), nums.end(), cpr);
ll ans = 1;
ll r = 0;
ll l = 0;
while(r != n && l != n)
{
while (nums[l] + diff >= nums[r] && l != n)
{
ans *= (l - r + 1);
ans = ans % INF;
l++;
}
r++;
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |