Submission #724538

# Submission time Handle Problem Language Result Execution time Memory
724538 2023-04-15T13:54:52 Z rastervc A Huge Tower (CEOI10_tower) C++17
100 / 100
281 ms 8716 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 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 988 KB Output is correct
2 Correct 23 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 120 ms 3716 KB Output is correct
2 Correct 111 ms 3688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 281 ms 8716 KB Output is correct
2 Correct 274 ms 8076 KB Output is correct