Logo
(追記) (追記ここまで)

16598번 - Achievements 다국어

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

문제

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
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /