AmazonOA #200
Max Consecutive ON Servers
估计中等可在线判题
One operation chooses any contiguous range and flips every 0 and 1 in it; at most k operations are allowed. Find the length of the longest contiguous run of 1s at the end. Operations may overlap, and you do not have to use all k.
输入格式
The first line contains the binary string; the second line contains k. 1≤length≤200000, 1≤k≤200000.
输出格式
Output a single integer, the answer.
样例 1
输入:
00010
1
输出:
4
样例 2
输入:
1001
2
输出:
4
样例 3
输入:
11101010110011
2
输出:
8
样例说明
The answers are 4, 4 and 8; flipping the last two runs of 0s directly gives length 8, with no need for the complicated overlapping operations used in the source.