AmazonOA #199
Get Max Alternating Music
估计中等可在线判题
In a binary string you may flip one character at a time, at most k times. Find the maximum length of a contiguous substring in which every pair of adjacent characters differs. It is a substring, not a subsequence, and flips apply to single characters, not to whole ranges.
输入格式
The first line contains the binary string; the second line contains k. This site uses 1≤length≤200000, 0≤k≤200000.
输出格式
Output a single integer, the answer.
样例 1
输入:
0000
1
输出:
3
样例 2
输入:
01010
0
输出:
5
样例 3
输入:
111
2
输出:
3
样例说明
The answers are 3, 5 and 3.