Arya has N balls arranged in a row. Some balls are colored and some are not. There are some M types of colors in Arya’s world and color balls have colors out of only these given M colors. Arya decided to color the remaining balls and put all the adjacent balls with the same color in 1 group. For example, lets say after coloring the rows of balls have these colors : {1, 2, 2, 3, 3, 3, 1, 1, 4, 5}. Then Arya can put them into following 6 groups : {1}, {2, 2}, {3, 3, 3}, {1, 1}, {4} and {5}. Arya wants the number of groups to be exactly K. Now the coloring also has some cost associated. So as already told that there are M colors, coloring each ball i with color j costs C(i, j). Arya want to use minimum paint for this task. You need to help her. It is guaranteed that we can paint the balls such that K groups are formed. Input Format:
The first line contains three integers, n, m and k (1 <=k<=n<= 100, 1<=m≤100)-the number of balls, number of colors and number of target groups
The second line contains n integers x1, x2, ..., xn (0<=xi<=m), the initial colors of the balls, xi equals to 0 if the ball number i is uncolored, otherwise the i-th ball has color xi.
Then n lines follow. Each of them contains m integers. The j-th number on the i-th of them line denotes C(i, j) (1 <c(i,j)s 109) - the cost to color i-th ball with j. c(i, j)'s are specified even for the initially colored balls, but such balls still can't be colored.
output format:
print a single integer, minimum amount of paint needed balls.
sample input 1:
3 2 2
0 0 0
1 2
3 4
5 6
sample output 1:
10
i am not able figure out how is given and understand question
What I have tried:
I have tried searching for answers on the web but only the question is available not the answer