HBC15421Sign Location题解

痛心疾首 算法基础篇 51 0
想要检验自己的编程水平?来试试全网最全C++题库,让您在挑战中不断进步。
Your task is to choose k locations to put signs . Let c(i,j) be the distance from the i-th station to the closest sign between station i and station j. c(i,j) = |xi - xj| if there's no sign between them. Find the optimal solution of the sign locations to minimize

There are n stations on the road, which are located at x1 ... xn (x1 < x2 < ... < xn). Your task is to choose k locations to put signs (signs could be put at anywhere, not necessary to be at a station). Let c(i,j) be the distance from the i-th station to the closest sign between station i and station j. c(i,j) = |xi - xj| if there's no sign between them. Find the optimal solution of the sign locations to minimize sum_{i neq j} c(i,j) ∑ i  ​ =j ​ c(i,j).

HBC15421Sign Location题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)

标签: HBC15421Sign Location题解