题目描述
You are given a sequence $A = (A_1, A_2, \ldots, A_N)$ of length $N$.
Find the maximum length of a subsequence of $A$ such that the absolute difference between any two adjacent terms is at most $D$.
A subsequence of a sequence $A$ is a sequence that can be obtained by deleting zero or more elements from $A$ and arranging the remaining elements in their original order.
- $1 \leq N \leq 5 \times 10^5$
- $0 \leq D \leq 5 \times 10^5$
- $1 \leq A_i \leq 5 \times 10^5$
- All input values are integers.