제출 #465048

#제출 시각아이디문제언어결과실행 시간메모리
465048deinfreundGlobal Warming (CEOI18_glo)C++14
27 / 100
298 ms14812 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, num, d; cin >> n >> d; map<int, int> blub, fred; blub[-d] = fred[-d] = 0; for (int i = 0; i < n; i++) { cin >> num; blub[num] = prev(blub.lower_bound(num))->second + 1; fred[num] = max(prev(blub.lower_bound(num + d))->second + 1, prev(fred.lower_bound(num))->second + 1); auto it = blub.find(num); int val = it->second; auto nextit = next(it); while(nextit != blub.end() && nextit->second < val) { blub.erase(nextit); nextit = next(blub.find(num)); } { auto it = fred.find(num); int val = it->second; auto nextit = next(it); while(nextit != fred.end() && nextit->second < val) { fred.erase(nextit); nextit = next(fred.find(num)); } } } cout << fred.rbegin()->second << "\n"; }
#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...