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

32318번 - Identical Letters 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 1024 MB63332856.000%

문제

Streak of identical letters always fascinates computer scientists and, as such, the scientists always look for such consecutive sequence of identical letters.

Given a string of lowercase letters and an integer m, determine the maximum number of consecutive identical letters in the string if you can remove up to m letters from the string. Note that you do not have to remove exactly m letters.

입력

The first input line provides the string (1 ≤ string length ≤ 2×105); it starts in column 1 and contains only lowercase letters. The second input line contains an integer, m (0 ≤ m ≤ string length), indicating the maximum number of letters you can remove from the string.

출력

Print the maximum number of consecutive identical letters in the string if you can remove up to m letters from the string.

제한

예제 입력 1

bbazbcbbbcybbx
2

예제 출력 1

5

예제 입력 2

bbazbcbbbcybbx
5

예제 출력 2

8

예제 입력 3

zabcadyhxwuy
5

예제 출력 3

2

힌트

For the first Sample Input, we can remove the two letters at positions 10 and 11.

For the second Sample Input, we can remove the letters at positions 3, 4, 6, 10 and 11.

For the third Sample Input, we can create ”…aa…” or ”…yy…”, each of length 2.

출처

University > University of Central Florida > 2024 Local Programming Contest (Final Round) 5번

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

출처

대학교 대회

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

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