CROC 2016 - Elimination Round
C
Enduring Exodus
Codeforces
1600
原题
← BD →
翻译中…

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

翻译中…

The first line of the input contains two integers $*n*$ and $*k*$ ($1 ≤ *k* < *n* ≤ 100 000$) — 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

翻译中…

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

翻译中…

Note

翻译中…

In the first sample, Farmer John can book room $3$ for himself, and rooms $1$ and $4$ for his cows. The distance to the farthest cow is $2$. Note that it is impossible to make this distance $1$, as there is no block of three consecutive unoccupied rooms.

翻译中…

In the second sample, Farmer John can book room $1$ for himself and room $3$ for his single cow. The distance between him and his cow is $2$.

翻译中…

In the third sample, Farmer John books all three available rooms, taking the middle room for himself so that both cows are next to him. His distance from the farthest cow is $1$.

翻译中…

样例

Input #1
7 2
0100100
Output #1
2
InputCopy OutputCopy
Input #2
5 1
01010
Output #2
2
InputCopy OutputCopy
Input #3
3 2
000
Output #3
1
InputCopy OutputCopy
题目信息
题号
645C
时间限制
2 s
内存限制
256 MB
标签
二分
双指针

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。