Submission #273791

# Submission time Handle Problem Language Result Execution time Memory
273791 2020-08-19T07:20:05 Z shrek12357 A Huge Tower (CEOI10_tower) C++14
35 / 100
593 ms 18852 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<int> nums;
	map<int, int> indexes;
	for (int i = 0; i < n; i++) {
		int temp;
		cin >> temp;
		nums.push_back(temp);
	}
	sort(nums.begin(), nums.end());
	int dp = 1;
	set<int> curNums;
	set<int>::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;
		}
		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 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 Incorrect 0 ms 256 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't 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 Incorrect 1 ms 256 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 512 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 768 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 71 ms 3552 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 420 ms 18852 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 593 ms 4512 KB Output isn't correct
2 Halted 0 ms 0 KB -