

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
長さ の数列 が与えられます。
の部分列であって、隣接する 項の差の絶対値が 以下であるようなものの長さの最大値を求めてください。
ただし、数列 の部分列とは、 の要素を 個以上選んで削除し、残った要素を元の順序を保って並べた数列のことを指します。
制約
- 入力される数値はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
出力
答えを出力せよ。
入力例 1Copy
4 2 3 5 1 2
出力例 1Copy
3
の部分列 は隣接する 項の差の絶対値が 以下です。
入力例 2Copy
5 10 10 20 100 110 120
出力例 2Copy
3
入力例 3Copy
11 7 21 10 3 19 28 12 11 3 3 15 16
出力例 3Copy
6
Score: points
Problem Statement
You are given a sequence of length .
Find the maximum length of a subsequence of such that the absolute difference between any two adjacent terms is at most .
A subsequence of a sequence is a sequence that can be obtained by deleting zero or more elements from and arranging the remaining elements in their original order.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1Copy
4 2 3 5 1 2
Sample Output 1Copy
3
The subsequence of has absolute differences of at most between adjacent terms.
Sample Input 2Copy
5 10 10 20 100 110 120
Sample Output 2Copy
3
Sample Input 3Copy
11 7 21 10 3 19 28 12 11 3 3 15 16
Sample Output 3Copy
6