CodeForces - 645C
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 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. Sample Input
Input
7 2 0100100
Output
2
Input
5 1 01010
Output
2
Input
3 2 000
Output
1 Source
//题意:输入n,m,接着输入一个长度为n的01串
表示一个人带着m头牛入住客栈,现在客栈里有n个房间,1表示已经有人住了,0表示没人住,现在问这个人和他的牛都入住客栈后,求这个人距离最远的那头牛的最短距离。
|
CodeForces - 645C Enduring Exodus (二分)
最新推荐文章于 2018-04-23 19:50:05 发布