QOJ.ac

QOJ

Time Limit: 5 s Memory Limit: 256 MB Total points: 100

#13072. 标记位置

الإحصائيات

路上有 $n$ 个车站,分别位于 $x_1$ ... $x_n$ ($x_1 < x_2 <$ ... $< x_n$) 处。

你的任务是选 $k$ 个放标志的地方 (标志的位置不局限于车站,也可以在其它地方) 。 令 $c(i,j)$ 表示第 $i$ 个站与第 $i$ 个和第 $j$ 个站之间离第 $i$ 个站最近的标记的距离,如果两个站直接没有标记,则 $c(i,j) = |x_i - x_j|$ ,则你需要合理选择标志的位置以最小化 $\sum_{i \neq j} c(i,j)$ 的值。

输入格式

输入包含多组测试数据,每组以两个整数 $n$ 和 $k$ 开始。

接下来的一行包含 $n$ 个整数 $x_1, \dots , x_n$ 。

输出格式

对于每个测试数据,输出一个整数,代表 $\sum_{i \neq j} c(i,j)$ 的最小值。

样例数据

样例 1 输入

4 0
1 2 3 4
4 1
1 2 3 4

样例 1 输出

20
11

子任务

对于 $100\%$ 的数据, $0 \leq k \leq 200, 2 \leq n \leq 10000 , 0 \leq x_1 < x_2 < \ldots < x_n \leq 10^7$ 。

特别鸣谢楼天城和吉如一提供试题,数据。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.