#K61742. Longest Contiguous Subarrays of Even and Odd Numbers

    ID: 31377 Type: Default 1000ms 256MiB

Longest Contiguous Subarrays of Even and Odd Numbers

Longest Contiguous Subarrays of Even and Odd Numbers

You are given an array of integers. Your task is to determine the lengths of the longest contiguous subarrays that consist of only even numbers and only odd numbers, respectively.

Input: The first line of input contains a single integer n representing the number of elements in the array. The second line contains n space-separated integers.

Output: Print a JSON string representing a dictionary with two keys: even and odd. The value associated with even is the length of the longest contiguous subarray consisting entirely of even numbers, and the value associated with odd is the length of the longest contiguous subarray consisting entirely of odd numbers.

Example:

Input:
9
4 2 1 3 5 6 8 10 7

Output: {"even":3,"odd":3}

</p>

The solution should read from standard input and write to standard output.

inputFormat

The input consists of two lines. The first line contains an integer n (1 ≤ n ≤ 105), which is the number of elements in the array. The second line contains n space-separated integers, each of which can be positive, negative, or zero.

outputFormat

Output a single line containing a JSON string with two keys: even and odd. The values must be the lengths of the longest contiguous subarrays of even and odd numbers respectively.

The output must be printed to stdout in the following format:

{"even": X, "odd": Y}
## sample
9
4 2 1 3 5 6 8 10 7
{"even":3,"odd":3}