Submission #273794

# Submission time Handle Problem Language Result Execution time Memory
273794 2020-08-19T07:20:59 Z shrek12357 A Huge Tower (CEOI10_tower) C++14
95 / 100
1000 ms 63512 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, int> indexes;
	for (int i = 0; i < n; i++) {
		long long 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;
	curNums.insert(nums[0]);
	indexes[nums[0]] = 0;
	int lol = 0;
	for (int i = 1; i < n; i++) {
		it = curNums.lower_bound(nums[i] - d);
		if (it == curNums.end()) {
			lol++;
		}
		else {
			dp = (dp * (i - indexes[*it] + 1) + MOD) % MOD;
		}
		curNums.insert(nums[i]);
		if (indexes.find(nums[i]) == indexes.end()) {
			indexes[nums[i]] = i;
		}
	}
	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 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 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 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 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 384 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 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 4284 KB Output is correct
2 Correct 68 ms 4720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 402 ms 22704 KB Output is correct
2 Correct 288 ms 8064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 603 ms 8628 KB Output is correct
2 Execution timed out 1048 ms 63512 KB Time limit exceeded