| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 (추가 시간 없음) | 1024 MB | 63 | 33 | 28 | 56.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.
bbazbcbbbcybbx 2
5
bbazbcbbbcybbx 5
8
zabcadyhxwuy 5
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.