#K77342. Identical Subarray Transformation

    ID: 34843 Type: Default 1000ms 256MiB

Identical Subarray Transformation

Identical Subarray Transformation

You are given an array of n integers along with two additional integers k and m. The goal is to determine the smallest number of modifications required so that there exists at least one contiguous subarray of length m (or more) in which all elements are identical. A modification consists of changing an element to any integer value.

Formally, given an array arr of length n, you are allowed to select any contiguous subarray of length m (you may assume m ≤ n) and change some of its elements so that every element in that subarray becomes the same. The minimum number of changes required for a particular subarray is the subarray length m minus the frequency of the most common element in that subarray. Your task is to find the minimum such value among all contiguous subarrays of length m.

Note: The parameter k is provided but is not used in the calculation. It is included to match the input format.

Mathematical Formulation: For a subarray S of length m, if f(x) is the frequency of element x in S, the number of modifications required is given by:

[ \text{changes}(S) = m - \max_{x} f(x) ]

Your answer is the minimum value of \(\text{changes}(S)\) taken over all contiguous subarrays of length m.

inputFormat

The input is read from standard input. The first line contains three space-separated integers: n, k, and m.

The second line contains n space-separated integers representing the array arr.

Constraints: It is guaranteed that m ≤ n. The parameter k is provided but not used in the problem.

outputFormat

Output a single integer which represents the minimum number of modifications required so that there exists at least one contiguous subarray of length m in which all elements are identical.

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