Submission #273794

#TimeUsernameProblemLanguageResultExecution timeMemory
273794shrek12357A Huge Tower (CEOI10_tower)C++14
95 / 100
1048 ms63512 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...