제출 #398997

#제출 시각아이디문제언어결과실행 시간메모리
398997KoDGlobal Warming (CEOI18_glo)C++17
100 / 100
67 ms4596 KiB
#include <bits/stdc++.h>

template <class T>
using Vec = std::vector<T>;

constexpr int INF = std::numeric_limits<int>::max() / 2;

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int N, X;
    std::cin >> N >> X;
    Vec<int> A(N);
    for (auto& x: A) {
        std::cin >> x;
    }    
    Vec<int> up(N + 1, INF), down(N + 1, INF);
    up[0] = down[0] = -INF;
    for (const auto x: A) {
        const int u = std::lower_bound(up.begin(), up.end(), x) - up.begin();
        const int d = std::lower_bound(down.begin(), down.end(), x) - down.begin();
        up[u] = x;
        down[d] = x;
        down[u] = std::min(down[u], x - X);
    }
    std::cout << std::lower_bound(down.begin(), down.end(), INF) - down.begin() - 1 << '\n';
    return 0;
}
#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...