14271: 【原4271】John and Cows

题目描述

author: Guo Linsong 原OJ链接：https://acm.sjtu.edu.cn/OnlineJudge-old/problem/4271

Description

In an attempt to escape the Mischievous Mess Makers' antics, Farmer John has abandoned his farm and is traveling to the other side of Bovinia. During the journey, he and his $k$ cows have decided to stay at the luxurious Grand Moo-dapest Hotel. The hotel consists of $n$ rooms located in a row, some of which are occupied.

Farmer John wants to book a set of $k + 1$ currently unoccupied rooms for him and his cows. He wants his cows to stay as safe as possible, so he wishes to minimize the maximum distance from his room to the room of his cow. The distance between rooms $i$ and $j$ is defined as $|j - i|$. Help Farmer John protect his cows by calculating this minimum possible distance.

Input Format

The first line of the input contains two integers $n$ and $k$ ($1 \leq k < n \leq 10^5$) — the number of rooms in the hotel and the number of cows travelling with Farmer John.

The second line contains a string of length $n$ describing the rooms. The $i$-th character of the string will be '0' if the $i$-th room is free, and '1' if the $i$-th room is occupied. It is guaranteed that at least $k + 1$ characters of this string are '0', so there exists at least one possible choice of $k + 1$ rooms for Farmer John and his cows to stay in.

Output Format

Print the minimum possible distance between Farmer John's room and his farthest cow.

Sample Input 1

7 2
0100100


Sample Output 1

2


Sample Input 2

5 1
01010


Sample Output 2

2


Oops! 本题目还没有解答！

OJ翻了一新，但本解答集还大多用的是2017-2019级，甚至更早的同学们贡献的答案。