#C3887. Unique Distinct Subarrays
Unique Distinct Subarrays
Unique Distinct Subarrays
You are given an array A of length N and an integer M. Your task is to find the number of unique contiguous subarrays of length M such that all elements in each subarray are distinct.
Formally, consider all subarrays A[i], A[i+1], ..., A[i+M-1] (with 0 ≤ i ≤ N - M). A subarray qualifies if all its M elements are different. Among qualifying subarrays, count each distinct subarray only once.
Note: Two subarrays are considered the same if they have identical elements in the same order.
The answer should be computed using standard input for input and standard output for output.
inputFormat
The first line contains two space-separated integers, N and M.
The next line contains N space-separated integers representing the array A.
Input is provided via stdin.
outputFormat
Output a single integer denoting the number of unique subarrays of length M that have all distinct elements.
Output should be printed to stdout.
## sample5 3
1 2 1 2 3
1