#C12114. Longest Consecutive Sequence

    ID: 41506 Type: Default 1000ms 256MiB

Longest Consecutive Sequence

Longest Consecutive Sequence

Given an array of integers, your task is to find the longest contiguous sequence of identical elements. In other words, identify the element that appears consecutively the most number of times and return both the element and its count.

If there are multiple sequences with the same maximum length, return the one that appears first in the array.

For an empty array, output None 0.

The answer should be computed using the following idea: traverse the array while tracking the current streak of identical numbers, and update your record if you find a longer streak. Mathematically, if the sequence is represented as \(a_1, a_2, \dots, a_n\), you are to find an index range \([i, j]\) such that \(a_k = c\) for all \(i \le k \le j\) and \(j-i+1\) is maximized.

inputFormat

The first line contains an integer \(n\) representing the number of elements in the array. The second line contains \(n\) integers separated by spaces. If \(n = 0\), the array is empty.

outputFormat

Output the element with the longest consecutive occurrence and the length of that occurrence separated by a single space. If the array is empty, output None 0.

## sample
10
1 1 2 2 2 3 3 1 1 1
2 3