Submission #273828

# Submission time Handle Problem Language Result Execution time Memory
273828 2020-08-19T07:31:02 Z shrek12357 A Huge Tower (CEOI10_tower) C++14
100 / 100
604 ms 8796 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
using namespace std;
 
#define MOD 1000000009
 
int main() {
	int n, d;
	cin >> n >> d;
	vector<long long> nums;
	//map<long long, long long> indexes;
	for (int i = 0; i < n; i++) {
		int temp;
		cin >> temp;
		nums.push_back(temp);
	}
	sort(nums.begin(), nums.end());
	long long dp = 1;
	//set<long long> curNums;
	//set<long long>::iterator it;
	vector<long long>::iterator it1;
	//curNums.insert(nums[0]);
	//indexes[nums[0]] = 0;
	int lol = 0;
	for (int i = 1; i < n; i++) {
		it1 = lower_bound(nums.begin(), nums.begin() + i, nums[i] - d);
		if (it1 == nums.end()) {
			lol++;
		}
		else {
			dp = (dp * (i - (it1 - nums.begin()) + 1)) % MOD;
		}
	}
	cout << dp << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 1020 KB Output is correct
2 Correct 48 ms 1012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 242 ms 2540 KB Output is correct
2 Correct 241 ms 2536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 604 ms 8796 KB Output is correct
2 Correct 591 ms 8668 KB Output is correct