luogu#P4870. [BalticOI 2009] 甲虫 (Day1)

    ID: 3861 远端评测题 4000ms 16MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>动态规划 DP2009区间 DPBalticOI(波罗的海)

[BalticOI 2009] 甲虫 (Day1)

Problem Description

Translated from BalticOI 2009 Day1 T1 “Beetle”.

A beetle is on a horizontal tree branch. Because it is obsessed with math, it feels like it is on the xx axis.

On the same branch, there are nn drops of dew. Each drop contains mm units of water. Relative to the beetle’s position, their coordinates are x1,x2,,xnx_1, x_2, \dots, x_n.

Obviously, the sun will be blazing that day. Every unit of time, each drop of dew loses 11 unit of water. The beetle suffers so much from the sun that whenever it touches a drop of dew, it can instantly drink it all. In each unit of time, it can move 11 unit of distance.

So you need to write a program that, given the coordinates of the dew drops, computes the maximum amount of water the beetle can drink.

Input Format

The first line contains two integers, nn and mm.

The next nn lines each contain one integer, giving the coordinates x1,x2,,xnx_1, x_2, \dots, x_n.

Output Format

Output one line containing the maximum amount of water the beetle can drink.

3 15
6
-3
1
25

Hint

Constraints: 0n3000 \le n \le 300, 1m1,000,0001 \le m \le 1{,}000{,}000, 10,000x1,x2,,xn10,000-10{,}000 \le x_1, x_2, \dots, x_n \le 10{,}000, and for all iji \ne j, xixjx_i \ne x_j.

Translated by ChatGPT 5