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, 22.06.2019 02:00
Aisha has finished working on a word processing document that contains 15 pages. she has added some special elements in the first three pages, page 9 and 10, and page 15 from the document. she wants to print only these pages to see how they look. which option is the correct way to represent (in the print dialog box) the pages that aisha wants to print?
Answers: 3
question
Computers and Technology, 22.06.2019 19:10
How might the success of your campaign be affected if you haven’t carefully completed all field data or if you accidentally insert the wrong merge field in the document?
Answers: 1
question
Computers and Technology, 23.06.2019 03:30
Hashtags serve to identify the topic of a given tweet true false
Answers: 2
question
Computers and Technology, 24.06.2019 07:30
Jason is working on a microsoft excel worksheet and he wants to create a print preview shortcut. his teacher asks him to access the customization option to create the new shortcut. which two tabs should jason select to place the print preview shortcut on the worksheet toolbar? a. new tab (custom) and new group (custom) b. new file tab (custom) and new tab (custom) c. new custom group and new command d. new custom tab and new command
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
Mathematics, 03.06.2020 20:10
question
Business, 03.06.2020 20:10
question
History, 03.06.2020 20:11
question
English, 03.06.2020 20:11
question
Mathematics, 03.06.2020 20:11
Questions on the website: 13722362