#K7271. Maximum Contiguous Sublists with Distinct Integers

    ID: 33814 Type: Default 1000ms 256MiB

Maximum Contiguous Sublists with Distinct Integers

Maximum Contiguous Sublists with Distinct Integers

You are given a list of (n) integers. Your task is to split the array into the maximum number of contiguous sublists such that each sublist contains only distinct integers.

More formally, given an array (A = [a_1, a_2, \dots, a_n]), you need to determine the maximum number (k) for which there exists a sequence of indices (1 = i_1 < i_2 < \dots < i_{k+1} = n+1) such that for each sublist (A[i_j, i_{j+1}-1]) (for (1 \leq j \leq k)), all elements are unique. This means that every time a repeated element is encountered, a new sublist must begin.

inputFormat

The input consists of two lines:
1. The first line contains a single integer (n) ( (1 \leq n \leq 10^5) ), representing the number of elements in the array.
2. The second line contains (n) space-separated integers representing the array elements.

outputFormat

Output a single integer — the maximum number of contiguous sublists into which the array can be split so that each sublist contains only distinct integers.## sample

5
1 2 3 1 2
3

</p>