Submission #914401

# Submission time Handle Problem Language Result Execution time Memory
914401 2024-01-22T02:32:27 Z ezGeometry A Huge Tower (CEOI10_tower) C++17
100 / 100
221 ms 11344 KB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int MOD = 1e9 + 9;

int main() {
	long long n, d;
	cin >> n >> d;

	vector<long long> arr(n);
	for (int i = 0; i < n; i++) { 
		cin >> arr[i];
	}

	sort(arr.begin(), arr.end());  // sort the blocks

	int r = 0;
	long long sol = 1;

	for (int i = 0; i < n; i++) {
		while (r + 1 < n && arr[r + 1] <= d + arr[i]) {
			r++;
		}
		sol *= ((long long)r - i + 1);
		sol %= MOD;
	}

	cout << sol << endl;

	return 0;
}
# 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 348 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 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 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 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 348 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 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 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 4 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 1116 KB Output is correct
2 Correct 22 ms 1204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 97 ms 4676 KB Output is correct
2 Correct 94 ms 4796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 216 ms 11344 KB Output is correct
2 Correct 221 ms 10652 KB Output is correct