Score : $600$ points
Given are integer sequences of length $N$ each: $A = (A_1, \dots, A_N)$ and $C = (C_1, \dots, C_N)$.
You can do the following operation any number of times, possibly zero.
After you are done with the operation, you have to pay $K \times X$ yen, where $K$ is the number of different values among the elements of $A$.
What is the minimum total amount of money you have to pay?
Input is given from Standard Input in the following format:
$N$ $X$ $A_1$ $C_1$ $\vdots$ $A_N$ $C_N$
Print a number representing the answer.
3 5 3 2 2 4 4 3
12
After adding $1$ to $A_1$, there will be two different values among the elements of $A$, for a total cost of $C_1 + 2 \times X = 12$ yen. It is impossible to make the total cost less than this.
1 1 1 1
1
7 7 3 2 1 7 4 1 1 8 5 2 9 8 2 1
29