subject
Computers and Technology, 21.04.2020 04:51 mandyO1

A terrible new disease, HORSEVID, has begun to spread among horses worldwide. Stable manager Jimmy is trying to take as many precautions as possible to protect his herd from infection.

Stable manager Jimmy's barn is a long narrow building containing N stalls in a row (2≤N≤105). Some of these stalls are currently occupied by horses, and some are vacant. Having read about the importance of "social distancing", Stable manager Jimmy wants to maximize D, where D is the distance between the closest two occupied stalls. For example, if stalls 3 and 8 are the closest that are occupied, then D=5.

Two new horses recently joined Jimmy's herd and he needs to decide to which formerly-unoccupied stalls they should be assigned. Please determine how he can place his two new horses so that the resulting value of D is still as large as possible. Stable manager Jimmy cannot move any of his existing horses; he only wants to assign stalls to the new horses.

INPUT:

The first line of input contains N.

The next line contains a string of length N of 0s and 1s describing the sequence of stalls in the barn. 0s indicate empty stalls and 1s indicate occupied stalls. The string has at least two 0s, so there is at least enough room for two new horses.

OUTPUT:

Please print the largest value of D

(the closest distance between two occupied stalls) that Stable manager Jimmy can achieve after adding his two new horses in an optimal fashion.

SAMPLE INPUT:

14
10001001000010

SAMPLE OUTPUT:
2
In this example, Stable manager Jimmy could add horses to make the occupancy string look like 10x010010x0010, where x's indicate the new horses. In this case D=2. It is impossible to add the new horses to achieve any higher value of D.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:00
What is the most important aspect of marking media? a. data labelingb. content descriptionc. electronic labelingd. classification
Answers: 2
question
Computers and Technology, 23.06.2019 00:30
Write the html code to make a link out of the text “all about puppies”. it should link to a pdf called “puppies.pdf” inside the “documents” folder. the pdf should open in a new window.
Answers: 2
question
Computers and Technology, 23.06.2019 08:30
All of these are true about using adhesive except: a. dissimilar materials can be joined. b. mixing tips are product and material specific. c. a specific application gun may be required. d. two-part adhesives are dispensed using two mixing tips
Answers: 3
question
Computers and Technology, 23.06.2019 09:50
Allison and her group have completed the data entry for their spreadsheet project. they are in the process of formatting the data to make it easier to read and understand. the title is located in cell a5. the group has decided to merge cells a3: a7 to attempt to center the title over the data. after the merge, allison points out that it is not centered and looks bad. where would the title appear if allison unmerged the cells in an attempt to fix the title problem?
Answers: 2
You know the right answer?
A terrible new disease, HORSEVID, has begun to spread among horses worldwide. Stable manager Jimmy i...
Questions
question
Arts, 10.06.2020 21:57
question
Physics, 10.06.2020 21:57
question
Mathematics, 10.06.2020 21:57
question
Mathematics, 10.06.2020 21:57
question
Mathematics, 10.06.2020 21:57
question
Mathematics, 10.06.2020 21:57
question
Mathematics, 10.06.2020 21:57
question
Mathematics, 10.06.2020 21:57
Questions on the website: 13722367