QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 2048 MB 總分: 100

#5488. 平台放置

统计

亚特兰蒂斯城正在建造一个水上区域。他们通过建造浮动平台来实现这一目标,这些平台以其中心锚定在海底的一条直线上的基准点上。每个平台都是一个固定宽度的矩形,与基准线对齐;具体来说,一个长度为 $\ell$、锚定在位置 $x$ 的平台,在海面上占据了区间 $[x - \frac{\ell}{2}, x + \frac{\ell}{2}]$。平台可以有不同的长度,但都有一个最小长度和一个最大长度。连续平台之间允许有间隙,平台之间可以刚好接触,但不能重叠。每个基准点必须且只能连接到一个平台。

请帮助亚特兰蒂斯人最大化他们的水上区域:给定基准点的位置以及允许的最小和最大平台长度,确定平台长度之和的最大可能值。

输入格式

输入的第一行包含三个空格分隔的整数 $n$ ($1 \le n \le 10^5$)、$s$ 和 $k$ ($1 \le s \le k \le 10^5$),其中 $n$ 是基准点的数量,$s$ 是可能的最小平台长度,$k$ 是可能的最大平台长度。

接下来的 $n$ 行,每行包含一个整数 $x$ ($1 \le x \le 10^9$),表示一个基准点的位置。任意两个基准点的位置均不相同。

输出格式

输出一个整数,表示平台长度之和的最大可能值;如果无法放置平台,则输出 $-1$。

样例

样例输入 1

4 1 4
1
6
8
10

样例输出 1

11

样例输入 2

5 1 6
6
7
8
3
5

样例输出 2

7

样例输入 3

2 5 10
1
2

样例输出 3

-1

Discussions

About Discussions

The discussion section is only for posting: 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.
  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.