Getting the same color
There are n students standing in a line, each of them is wearing clothes of one certain color. There is total m different colors, so each color can be represented by a single number from 0 to m-1.Teacher Wu wants to let his students wear clothes of the same color, so he need some operations. As we all know teacher Wu is an erratic person, if one student is wearing clothes of i-th color and teacher Wu wants to change this student’s color, he only asks this student to wear ((i+1)%m)-th color in one operation. What’s more, in one operation, teacher Wu always let the t consecutive students change their colors. Now here comes the problem, give you the number n,m,t,（n < 2000, m < 150, t < n）and all students’ clothes color, you are required to calculate the least operations through which all the students can wear clothes of the same color.
For every test case, there is one line containing three positive integers n, m, t, followed by some lines containing n numbers ai(0<=ai<=m-1) indicating the color of the i-th student’s clothes.
1 7 2 3 0 0 1 0 1 0 0
0 1 1 1 0 1 1 1 1 0 1 1 0 0 1 1 1 1 0 1 0 0 0 1 0 0 0 1