I was asked this problem in Bytedance OA.
N points are given on a line and there are K special points. You have to find the sum of shortest distances from each point to any special point. I know a solution like grouping points, and then for each group, sum of distances to their median, but it didn't work that time. I am thinking some DP but unable to figure out.
Constraints are N, K <= 100
Coordinates of points 1 <= C[i] <= 10^4.