Submit | All submissions | Best solutions | Back to list |
ZUMA - ZUMA |
One day Mirko, while he was walking through the high grass, stumbled upon a sequence of N colored marbles. Soon he noticed that if he touches K or more consecutive marbles of the same color, they start to twinkle and then he could wish them to magically vanish, although he doesn't have to do that immediately (see 2. sample). Fortunately, Mirko brought an inexhaustible supply of marbles from home, so he can insert a marble of any color anywhere in the array (at the beginning, between any two existing marbles, or at the end). Help Mirko find the smallest number of marbles he must insert into the sequence before he could make all of the marbles vanish
Input
The first line of input contains two integers N (1 ≤ N ≤ 100) and K (2 ≤ K ≤5) - the number of marbles in the initial sequence and the minimal number of consecutive marbles of the same color he could wish to vanish. The next line contains exactly N integers between 1 and 100 (inclusive),separated by one space. Those numbers represent colors of marbles in the sequence Mirko found.
Output
The output should contain only one line with a single integer number - the minimal number of marbles Mirko has to insert to achieve the desired effect.
Example
Input:
2 5
1 1
Output:
3
Input
10 4
3 3 3 3 2 3 1 1 1 3
Output:
4
Added by: | Phan Công Minh |
Date: | 2010-03-14 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: NODEJS OBJC PERL6 SQLITE VB.NET |
Resource: | COCI 2009-1010 |
hide comments
2017-05-21 17:46:56
In the second exemple, the output should be 3? If he touchs the 1 sequence, than the 2 sequence, then the 3 sequence, it will be over and he has touched 3 sequences. |
|
2013-07-21 12:32:27 31113
getting wa frequently.give me some more test cases |