이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 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... |