C1738 [CEOI2018Day1] Global warming

内存限制:256 MB 时间限制:1000 ms

题目描述

Global warming is an important issue and Johnny knows about it. He decided to make an analysis of historical temperatures and find a subsequence of days (not necessarily consecutive) where the temperature was strictly increasing. It will convince the non-believers!

Johnny has found historical data from $n$ consecutive days. The temperature on the $i$-th day was $t_i$.

Formally, we are interested in finding the length of the longest increasing subsequence (LIS) of $(t_1,t_2,...,t_n)$, that is, the largest possible $k$ for which it is possible to choose an increasing sequence of indices $1 ≤ a_1 < a_2 < ... < a_k ≤ n$ such that $t_{a_1} < t_{a_2} < ... < t_{a_k}$.

Johnny wants to find a really long subsequence and that is why he decided to cheat a bit. He will first choose a non-empty interval of days and an integer $d (−x ≤ d ≤ x)$ and he will increase the temperature in each of those days by $d$. A small change like that probably will not be noticed by the community, while at the same time it should make the LIS longer. It is allowed to choose $d = 0$.

What is the largest possible length of the LIS after a change?

输入格式

The first line of the standard input contains two space-separated integers $n$ and $x (1 ≤ n ≤ 200000, 0 ≤ x ≤ 10^9)$, the number of days and the limit for the absolute value of $d$.

The second line contains $n$ integers $t_1,t_2,...,t_n (1 ≤ t_i ≤ 10^9)$ separated by spaces, the sequence of historical temperatures.

输出

Print one integer, the largest possible length of the LIS after a single change.

样例

样例输入 1

8 10 7 3 5 12 2 7 3 4

样例输出 1

5

提示

Grading

The test set is divided into the following subtasks with additional constraints. Tests in each of the subtasks consist of one or more separate test groups. Each test group may contain one or more test cases.

image.png