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$ 。

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

Discussions

About Discussions

The discussion section is only for posting: Editorials, General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues. Submitting multiple issues may cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.