#K37712. Longest Non-Zero Consecutive Sequence
Longest Non-Zero Consecutive Sequence
Longest Non-Zero Consecutive Sequence
You are given an integer n and a sequence of n integer scores. A score of zero indicates a missed attempt. Your task is to find the length of the longest contiguous subsequence where all the scores are non-zero.
The problem can be mathematically viewed as follows:
Given a sequence \(a_1, a_2, \dots, a_n\), find the maximum \(k\) such that there exists an index \(i\) with \(a_i \neq 0, a_{i+1} \neq 0, \dots, a_{i+k-1} \neq 0\).
Note: The input is provided via standard input and the required output should be printed to standard output.
inputFormat
The first line contains a single integer n (the number of scores).
The second line contains n space-separated integers representing the scores.
outputFormat
Output a single integer, the length of the longest sequence of consecutive non-zero scores.
## sample10
1 2 0 4 5 6 0 0 7 8
3