문제
Bessie has been playing the popular fighting game Moortal Cowmbat for a long time now. However, the game developers have recently rolled out an update that is forcing Bessie to change her play style.
The game uses
It takes
Help Bessie determine the smallest possible number of days she needs to create a combo that supports the new requirements.
SCORING:
Test cases 2-4 satisfy
N\le 1000, K\le 50. Test cases 5-8 satisfy
N\le 30,000, K\le 50.
Problem credits: Eric Wei
입력
The first line of input contains
출력
Output a single number, representing the minimum number of days Bessie needs to change her combo into one that satisfies the new requirements.
예제1
5 5 2
abcde
0 1 4 4 4
2 0 4 4 4
6 5 0 3 2
5 5 5 0 4
3 7 0 5 0
5
The optimal solution in this example is to change the a into b, change the d into e, and then change both e’s into c’s. This will take