Thumbtacks
InterviewTime limit1sMemory limit128 MB
Find the smallest jump that crosses the bridge using only planks without thumbtacks.
- Level
Easy2 of 10
- Topics
- Array
- Solved
- No attempts yet
Problem
Jas is on his way home and must cross a bridge, but someone has laid a straight line of thumbtacks across it. The bridge is so narrow that there is no way to step around them, so the thumbtacks have to be jumped over. They are not all packed together: here and there are spots where Jas can put his foot down.
The bridge is made of planks, and each plank may hold a thumbtack. Jas can stand on a plank without a thumbtack, but not on one that has a thumbtack. We want to know how strong a jump Jas needs in order to reach the other side of the bridge. The jump length is the maximum number of planks Jas can clear in a single jump.
Input
The first line contains one integer (), the number of planks that make up the bridge. The second line contains integers , each equal to or , where describes the -th plank: if the plank has no thumbtack, if it does.
Output
Print a single integer: the jump length Jas must have in order to get to the other side of the bridge.