#K40662. Longest Sequence of Empty Benches
Longest Sequence of Empty Benches
Longest Sequence of Empty Benches
You are given an integer n and a list of n integers representing bench states, where 0
denotes an empty bench and 1
denotes an occupied bench. Your task is to determine the length of the longest contiguous sequence of empty benches.
This can be formulated mathematically as finding:
$$\max_{\text{segment}}\, \text{(number of consecutive }0\text{'s)}$$
Print the maximum count of consecutive 0
's.
inputFormat
The first line contains a single integer n
(1 ≤ n ≤ 105), representing the number of benches.
The second line contains n
space-separated integers, each being either 0
or 1
, indicating the state of each bench.
outputFormat
Output one integer — the length of the longest contiguous sequence of empty benches.
## sample5
1 1 1 1 1
0