It's Christmas time, which means it's time for a very sunny secret santa!!! This year, Max (Sun) begs Aaron to buy him a guitar; he's always wanted to play, but never had the time to learn. On Christmas Day, Max rushes downstairs to open the massive gift-box that Aaron sent him.
Max doesn't want to disrespect Aaron's gift, so he tries to learn as many chords as he can on the guitar. His new guitar contains different strings, the of which has a wavelength of . Max doesn't know how to use the guitar fretboard, so he decides to only play open strings. In other words, Max will only be able to make one note for each string on his guitar.
Max defines a chord as a consecutive subset of strings. The quality of a chord is defined as , where is the most frequent wavelength and is the number of times it is played in a chord. If two wavelengths are equally frequent, is equal to the higher value.
Additionally, Max has fingers. Each of these fingers can play up to one distinct string. Given these constraints, Max wonders how many unique chord qualities he can learn to impress Aaron. As Max's best friend, please help him out!
Input Specification
The first line will contain two integers, and (), the number of strings on Max's new guitar and the number of fingers Max has.
The second line will contain space-separated integers (), which denotes the wavelength of the string when played open.
Output Specification
Output one integer, the number of unique chord qualities he can play given the constraints.
Subtasks
Subtask 1 [10%]
All are distinct.
Subtask 2 [20%]
Subtask 3 [70%]
No additional constraints.
Sample Input 1
7 2
1 1 2 3 3 2 1
Sample Output 1
4
Sample Explanation 1
With one finger, Max can create the following chords with qualities of:
- with , and
- with and
- with and
With two fingers, Max can create chords with qualities of:
- with , and
- with and
- with
Thus, the set of distinct qualities Max can create is .
Sample Input 2
20 10
1 3 5 7 1 3 5 7 1 3 5 7 12 2 12 2 1 2 3 1
Sample Output 2
14
Comments