Submission #879563

# Submission time Handle Problem Language Result Execution time Memory
879563 2023-11-27T16:23:02 Z serifefedartar A Huge Tower (CEOI10_tower) C++17
100 / 100
121 ms 11236 KB
#include <bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(0);cin.tie(0);
#define s second
#define f first
typedef long long ll;
const ll MOD = 1e9 + 9;
const ll LOGN = 21;
const ll MAXN = 1e6 + 100;

vector<int> A;
int plc[MAXN];

int main() {
	fast
	int N, D;
	cin >> N >> D;

	A = vector<int>(N);
	for (int i = 0; i < N; i++)
		cin >> A[i];
	sort(A.begin(), A.end());

	for (int i = 0; i < N; i++)
		plc[i] = upper_bound(A.begin(), A.end(), A[i] + D) - A.begin();

	ll ans = 1;
	for (int i = 0; i < N; i++)
		ans = (ans * (plc[i] - i) % MOD);
	cout << ans << "\n";
}
# 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 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 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 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 456 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 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 3160 KB Output is correct
2 Correct 8 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 5924 KB Output is correct
2 Correct 40 ms 5924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 96 ms 11236 KB Output is correct
2 Correct 121 ms 10672 KB Output is correct