QOJ.ac

QOJ

时间限制: 1 s 内存限制: 128 MB 总分: 100

#16239. Beetle

统计

一只甲虫发现自己在一根细长的水平树枝上。“我坐在一根细长的水平树枝上,”甲虫心想,“这感觉就像是在 $x$ 轴上一样!”这确实是一只有着深刻数学思想的甲虫。

树枝上还有 $n$ 滴露水,每滴露水含有 $m$ 单位的水。以甲虫所在位置为原点(即坐标 $0$),它们的整数坐标分别为 $x_1, x_2, \dots, x_n$。

显然,今天会很热。每过一个单位的时间,每滴露水就会蒸发掉一个单位的水。甲虫很渴。它渴到一旦碰到一滴露水,就会在瞬间($0$ 时间内)将其喝掉。在每一个单位时间内,甲虫可以爬行一个单位的长度。但是,所有的这些爬行是否值得呢?这就是让甲虫感到困惑的地方。

因此,你需要编写一个程序,在给定露水坐标的情况下,计算甲虫最多可以喝到多少水。

输入格式

输入从标准输入读取。

第一行包含两个整数 $n$ 和 $m$。

接下来的 $n$ 行包含整数坐标 $x_1, x_2, \dots, x_n$。

输出格式

程序应向标准输出写入一行,包含一个整数:甲虫最多可以喝到的水量。

样例

输入样例 1

3 15
6
-3
1

输出样例 1

25

数据范围

  • $0 \le n \le 300$
  • $1 \le m \le 1,000,000$
  • $-10,000 \le x_1, x_2, \dots, x_n \le 10,000$
  • 对于 $i \neq j$,有 $x_i \neq x_j$

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

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.