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 <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <numeric>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(a, b) for(ll i=a; i < (ll) b; i++)
#define endl '\n'
#define MOD (ll) 1000000007ll
#define TESTCASE ll t; cin >> t; for(ll T=0; T < t; T++)
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
const ll INIT = 7;
const ll MAX_VAL = (ll) 1e9;
const ll MULT = (ll) 1e11;
const double eps = 1e-5;
vi rd = {0, 0 , 1, -1}, cd = {1, -1, 0 , 0};
int main() {
fast
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
// TESTCASE {
// }
ll n, d;
cin >> n >> d;
vll blocks(n + 1);
FOR(1, n + 1) cin >> blocks[i];
sort(blocks.begin(), blocks.end());
vll tr(n + 1, 1);
ll p=1;
FOR(1, n + 1) {
p = max(p, i);
while(p < n) {
if(blocks[i] + d >= blocks[p + 1]) p++;
else break;
}
tr[i] += (p - i);
// cout << p << " " << i << endl;
}
ll ans = 1;
FOR(1, n + 1) {
ans *= tr[i];
ans %= MOD;
}
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... |