luogu#P4870. [BalticOI 2009] 甲虫 (Day1)
[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 axis.
On the same branch, there are drops of dew. Each drop contains units of water. Relative to the beetle’s position, their coordinates are .
Obviously, the sun will be blazing that day. Every unit of time, each drop of dew loses 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 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, and .
The next lines each contain one integer, giving the coordinates .
Output Format
Output one line containing the maximum amount of water the beetle can drink.
3 15
6
-3
1
25
Hint
Constraints: , , , and for all , .
Translated by ChatGPT 5