Submission #273812

# Submission time Handle Problem Language Result Execution time Memory
273812 2020-08-19T07:28:35 Z shrek12357 A Huge Tower (CEOI10_tower) C++14
100 / 100
628 ms 8788 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) % 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 1 ms 512 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 384 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 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 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 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 50 ms 1012 KB Output is correct
2 Correct 49 ms 1012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 244 ms 2540 KB Output is correct
2 Correct 246 ms 2692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 628 ms 8788 KB Output is correct
2 Correct 565 ms 8668 KB Output is correct