CF847D.Dog Show

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A new dog show on TV is starting next week. On the show dogs are required to demonstrate bottomless stomach, strategic thinking and self-preservation instinct. You and your dog are invited to compete with other participants and naturally you want to win!

On the show a dog needs to eat as many bowls of dog food as possible (bottomless stomach helps here). Dogs compete separately of each other and the rules are as follows:

At the start of the show the dog and the bowls are located on a line. The dog starts at position x=0x=0 and nn bowls are located at positions x=1,x=2,...,x=nx=1,x=2,...,x=n . The bowls are numbered from 11 to nn from left to right. After the show starts the dog immediately begins to run to the right to the first bowl.

The food inside bowls is not ready for eating at the start because it is too hot (dog's self-preservation instinct prevents eating). More formally, the dog can eat from the ii -th bowl after tit_{i} seconds from the start of the show or later.

It takes dog 1 second to move from the position xx to the position x+1x+1 . The dog is not allowed to move to the left, the dog runs only to the right with the constant speed 1 distance unit per second. When the dog reaches a bowl (say, the bowl ii ), the following cases are possible:

  • the food had cooled down (i.e. it passed at least tit_{i} seconds from the show start): the dog immediately eats the food and runs to the right without any stop,
  • the food is hot (i.e. it passed less than tit_{i} seconds from the show start): the dog has two options: to wait for the ii -th bowl, eat the food and continue to run at the moment tit_{i} or to skip the ii -th bowl and continue to run to the right without any stop.

After TT seconds from the start the show ends. If the dog reaches a bowl of food at moment TT the dog can not eat it. The show stops before TT seconds if the dog had run to the right of the last bowl.

You need to help your dog create a strategy with which the maximum possible number of bowls of food will be eaten in TT seconds.

输入格式

Two integer numbers are given in the first line - nn and TT ( 1<=n<=2000001<=n<=200000 , 1<=T<=21091<=T<=2·10^{9} ) — the number of bowls of food and the time when the dog is stopped.

On the next line numbers t1,t2,...,tnt_{1},t_{2},...,t_{n} ( 1<=ti<=1091<=t_{i}<=10^{9} ) are given, where tit_{i} is the moment of time when the ii -th bowl of food is ready for eating.

输出格式

Output a single integer — the maximum number of bowls of food the dog will be able to eat in TT seconds.

输入输出样例

  • 输入#1

    3 5
    1 5 3
    

    输出#1

    2
    
  • 输入#2

    1 2
    1
    

    输出#2

    1
    
  • 输入#3

    1 1
    1
    

    输出#3

    0
    

说明/提示

In the first example the dog should skip the second bowl to eat from the two bowls (the first and the third).

首页