CF645C.Enduring Exodus

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 kk cows have decided to stay at the luxurious Grand Moo-dapest Hotel. The hotel consists of nn rooms located in a row, some of which are occupied.

Farmer John wants to book a set of k+1k+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 ii and jj is defined as ji|j-i| . Help Farmer John protect his cows by calculating this minimum possible distance.

输入格式

The first line of the input contains two integers nn and kk ( 1<=k<n<=100000 ) — the number of rooms in the hotel and the number of cows travelling with Farmer John.

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

输出格式

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

输入输出样例

  • 输入#1

    7 2
    0100100
    

    输出#1

    2
    
  • 输入#2

    5 1
    01010
    

    输出#2

    2
    
  • 输入#3

    3 2
    000
    

    输出#3

    1
    

说明/提示

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

In the second sample, Farmer John can book room 11 for himself and room 33 for his single cow. The distance between him and his cow is 22 .

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 11 .

首页