100 atcoder#ABC124D. [ABC124D] Handstand
[ABC124D] Handstand
Score : points
Problem Statement
people are arranged in a row from left to right.
You are given a string of length consisting of 0
and 1
, and a positive integer .
The -th person from the left is standing on feet if the -th character of is 0
, and standing on hands if that character is 1
.
You will give the following direction at most times (possibly zero):
Direction: Choose integers and satisfying , and flip the -th, -th, , and -th persons. That is, for each , the -th person from the left now stands on hands if he/she was standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of consecutive people standing on hands after at most directions.
Constraints
- is an integer satisfying .
- is an integer satisfying .
- The length of the string is .
- Each character of the string is
0
or1
.
Input
Input is given from Standard Input in the following format:
Output
Print the maximum possible number of consecutive people standing on hands after at most directions.
5 1
00010
4
We can have four consecutive people standing on hands, which is the maximum result, by giving the following direction:
- Give the direction with , which flips the first, second and third persons from the left.
14 2
11101010110011
8
1 1
1
1
No directions are necessary.