#K8141. Longest Even Subarray
Longest Even Subarray
Longest Even Subarray
Given an array of integers, your task is to find the length of the longest contiguous subarray that consists solely of even numbers. An integer is considered even if it satisfies the condition \( n \mod 2 = 0 \). This problem requires you to scan the array and determine the maximum length of such a continuous segment.
Example: For the array [1, 2, 4, 6, 1, 2, 4, 6, 8, 10], the longest contiguous even subarray is [2, 4, 6, 8, 10] and its length is 5.
inputFormat
The input is given via standard input (stdin). The first line contains an integer ( n ) representing the size of the array. The second line contains ( n ) space-separated integers representing the elements of the array.
outputFormat
Output a single integer to standard output (stdout), which is the length of the longest contiguous subarray consisting only of even numbers.## sample
10
1 2 4 6 1 2 4 6 8 10
5