#C6815. Longest Non-Negative Streak
Longest Non-Negative Streak
Longest Non-Negative Streak
You are given a sequence of integers. Your task is to find the length of the longest consecutive subsequence (streak) in which all the numbers are non-negative. A non-negative number is any integer that is greater than or equal to zero.
For example, if the input sequence is:
-1 2 3 -5 4 0 -2 3 4 5
Then the longest streak of non-negative numbers is 4 0
(which has a length of 3) because after that streak, a negative number appears and resets the count.
Note: The streak must consist of consecutive elements in the sequence.
inputFormat
The first line contains a single integer n, the number of elements in the sequence. The second line contains n integers separated by spaces.
Example:
10 -1 2 3 -5 4 0 -2 3 4 5
outputFormat
Output a single integer which represents the length of the longest consecutive streak where each number is non-negative.
Example:
3## sample
10
-1 2 3 -5 4 0 -2 3 4 5
3
</p>