-->
当前位置:首页 > 题库

PROGRAMMING:Keven's money making plan

Luz5年前 (2021-05-10)题库477
As we all know, demacia didn't have buildings before. Keven smelled business opportunities, so he recently built a lot of new buildings in demacia and planned to make a lot of money by selling houses.
However, Jiawen IV, the prince of demacia with obsessive-compulsive disorder, issued a strange decree that the height difference between any two houses in demacia must be less than or equal to m meters.
This is very difficult for Keven. According to the survey, the cost of adding or reducing $$k $$meters to a building is $$k ^ 2 $$gold coins, but Keven still wants to make more money. Can you help Keven figure out how many gold coins he needs to spend at least to meet the requirements of Jiawen IV?
###Input format:
The first line of input contains two integers n, m ($$1 < = n, m < = 2e5 $$)
The next line contains n integers representing the height of each house ($$1 < = h < = 2e5 $$).
###Output format:
Output an integer on a line to represent the lowest cost of Keven.
###Input example:
Here is a set of inputs. For example:
```in
4 23
40 21 44 46
```
###Output example:
The corresponding output is given here. For example:
```out
two
```







answer:If there is no answer, please comment