#K80127. Longest Good Clues Segment
Longest Good Clues Segment
Longest Good Clues Segment
You are given a sequence of n clues represented by an array C = [c_1, c_2, \ldots, c_n] where each clue c_i is either 1 (good) or 0 (bad). Your task is to determine the length of the longest consecutive segment of good clues.
Mathematically: Find the maximum length L such that there exists an index i with
\(L = \max\{ k \mid c_i = c_{i+1} = \cdots = c_{i+k-1} = 1 \}\)
This is a straightforward problem that tests your ability to process arrays and implement simple iteration. Make sure to handle edge cases where the array might contain all bad clues or just a single clue.
inputFormat
The input is given from stdin and consists of two lines:
- The first line contains a single integer n (\(1 \leq n \leq 10^5\)) representing the number of clues.
- The second line contains n space-separated integers, each of which is either 0 or 1.
outputFormat
Print a single integer to stdout representing the length of the longest consecutive segment of good clues.
## sample10
1 0 1 1 0 1 1 1 0 1
3