Submission #480541

# Submission time Handle Problem Language Result Execution time Memory
480541 2021-10-16T22:15:20 Z haddrthegoat A Huge Tower (CEOI10_tower) C++14
100 / 100
305 ms 2756 KB
#include <bits/stdc++.h>

using namespace std;

const int MOD = 1e9 + 9;

int main () {
	int n, d;
	cin >> n >> d;
	vector<int> ar(n);
	for (int i = 0; i < n; i++) {
		cin >> ar[i];
	}
	sort(ar.begin(), ar.end()); //sort the blocks
	int r = 0, sol = 1;
	for (int l = 0; l < n; l++) {
		while (r < n - 1 && ar[r + 1] - ar[l] <= d) r++;
		int dist = r - l + 1; //largest tower we can built when ar[l] block is the base
		sol = (sol * 1LL * dist) % MOD;
	}
	cout << sol << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 460 KB Output is correct
2 Correct 25 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 137 ms 1260 KB Output is correct
2 Correct 131 ms 1256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 290 ms 2636 KB Output is correct
2 Correct 305 ms 2756 KB Output is correct