Task
A sequence of natural numbers is called -dominant for given values and if:
- There are at least distinct numbers in the sequence.
- We can choose distinct numbers from the sequence such that the sum of their frequencies is greater than or equal to .
For example, for and :
- The sequence is -dominant (we can choose the numbers and , which appear a total of times in the sequence).
- The sequence is not -dominant (there are not two distinct values in the sequence).
- The sequence is not -dominant (there are not two distinct values in the sequence that appear a total of at least times).
Given , and a sequence of natural numbers ,
Find the number of -dominant subarrays of the sequence .
Input data
The first line of the file dominant.in
contains the numbers , , and .
The second line contains the sequence .
Output data
The first line of the file dominant.out
will display the number of -dominant subarrays of the sequence .
Constraints and clarifications
- number of distinct values in the sequence
- To obtain points for a specific subtask, at least one source sent must pass all tests in that subtask.
# | Points | Constraints |
---|---|---|
0 | 0 | Examples |
1 | 25 | |
2 | 22 | |
3 | 16 | |
4 | 19 | |
5 | 18 | No other constraints |
Example 1
dominant.in
4 3 1
1 2 3 4
dominant.out
3
Explanation
The -dominant subarrays are , , and .
Example 2
dominant.in
10 2 4
1 1 1 2 1 2 2 2 1 2
dominant.out
28
Explanation
There are a total of KaTeX parse error: Can't use function '$' in math mode at position 3: 28$̲
xy[1,1,1,2][2,1,2,2][1,1,1,2,1,2,2,2,1,2]$.
Example 3
dominant.in
14 3 8
5 3 5 1 4 5 1 4 2 2 4 5 4 4
dominant.out
15
Explanation
There are a total of KaTeX parse error: Can't use function '$' in math mode at position 3: 15$̲
xy[5,3,5,1,4,5,1,4,2,2,4]$.