시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB95352758.696%

문제

Did you know that Greg practices his Swedish skills every day? Well, almost every day.

The app that Greg uses to learn languages gives out achievement badges to keep you engaged with the app. One of the achievements is for the longest streak, i.e., the highest number of consecutive days that Greg practices Swedish. Remember that Greg does not practice every day, so there are gaps. Fortunately, the app allows him to pay for the days where he did not practice and still obtain the achievement.

Given the days when Greg actually practiced his Swedish and the number of days he is willing to pay for, what is the longest streak he can reach?

입력

The input consists of:

  • One line with two integers n and p (1 ≤ n, p ≤ 2 · 105), where n is the number of days Greg practiced with the app and p is the number of days that he is willing to pay for.
  • One line with n distinct integers d1, . . . , dn (0 ≤ d1 < d2 < . . . < dn ≤ 106), the days when Greg actually practiced.

출력

Output the length of the longest streak that Greg can reach when using the paid days in an optimal way.

예제 입력 1

5 2
3 5 6 10 11

예제 출력 1

5

예제 입력 2

2 2018
42 424242

예제 출력 2

2019

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > NWERC 2018 PA번

  • 문제를 만든 사람: Tobias Werth