K-Distinct Windows
View as PDF
Submit solution
Points:
100
Time limit:
1.0s
PyPy 3
2.0s
Python 3
2.0s
Memory limit:
500M
Problem type
Given an array of
integers, count how many subarrays of length exactly
contain at
least
distinct values.
Remember that a subarray is a contiguous section of the array.
Input
The first line contains three integers ,
, and
.
The second line contains integers
.
Output
Print a single integer: the number of subarrays of length exactly that contain at least
distinct values.
Constraints
Example 1
Input
8 4 3
1 1 2 3 2 2 1 4
Output
4
Explanation
The five subarrays of length are:
, which has
distinct values;
, which has
distinct values;
, which has
distinct values;
, which has
distinct values;
, which has
distinct values.
So the answer is .
Comments