Submission #923864

# Submission time Handle Problem Language Result Execution time Memory
923864 2024-02-08T03:31:29 Z hqminhuwu A Huge Tower (CEOI10_tower) C++14
100 / 100
92 ms 12664 KB
#include <bits/stdc++.h>
#define forr(_a,_b,_c) for(_a = (_b); _a <= (_c); ++_a)
#define ford(_a,_b,_c) for(_a = (_b) + 1; _a --> (_c);)
#define forf(_a,_b,_c) for(_a = (_b); _a < (_c); ++_a)
#define st first
#define nd second
#define ll long long
#define ull unsigned long long
#define pii pair <int,int>
#define pll pair <ll,ll>
#define piii pair <int,pii>
#define vi vector <int>
#define pb push_back
#define mp make_pair
#define all(x) begin(x),end(x)
#define file "test"


using namespace std;
const int N = 2e6 + 5;
const ll oo = 1e9;
const ll mod = 1e9 + 9;

ll n, i, a[N], d, ans = 1;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	#ifdef hqm
	   freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);
	#endif

	cin >> n >> d;
	forr (i, 1, n)
		cin >> a[i];

	sort(a + 1, a + 1 + n, greater<int>());
	
	ll r = 1;
	a[n + 1] = -2 * oo - 1;
	
	forr (i, 1, n){
		r = max (r, i);
		while (a[i] - a[r + 1] <= d)
			r++;
		ans = (ans * (r - i + 1)) % mod;
	//	cout << a[i] << " " << r << "\n";
	}

	cout << ans;
	return 0;
}
/*



*/

# Verdict Execution time Memory Grader output
1 Correct 4 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 3164 KB Output is correct
2 Correct 7 ms 3416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 4956 KB Output is correct
2 Correct 36 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 77 ms 12664 KB Output is correct
2 Correct 92 ms 12112 KB Output is correct