이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
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));
}
fred[num] = max(prev(blub.lower_bound(num + d))->second + 1, prev(fred.lower_bound(num))->second + 1);
{
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |