#C10686. Longest Contiguous Subarray with Identical Elements

    ID: 39918 Type: Default 1000ms 256MiB

Longest Contiguous Subarray with Identical Elements

Longest Contiguous Subarray with Identical Elements

Given an array of integers, your task is to find the length of the longest contiguous subarray in which all elements are identical. In other words, if the sequence has several consecutive occurrences of the same number, you need to determine the maximum count of these consecutive numbers.

Note: The input will be provided via standard input (stdin) and the result should be printed to standard output (stdout).

Mathematically, if the array is represented as \( a_1, a_2, \dots, a_n \), you need to find the maximum value of \( k \) such that for some index \( i \) (\(1 \leq i \leq n-k+1\)) it holds that \( a_i = a_{i+1} = \cdots = a_{i+k-1} \).

inputFormat

The input is given in two parts:

  1. An integer \( n \) representing the number of elements in the array.
  2. \( n \) space-separated integers representing the elements of the array.

If \( n = 0 \), the array is empty.

outputFormat

Output a single integer which is the length of the longest contiguous subarray where all elements are the same.

## sample
8
1 1 2 2 2 3 3 4
3