Farmer John has N hills on his farm (1 <= N <= 1,000), each with an integer elevation in the range 0 .. 100. In the winter, since there is abundant snow on these hills, FJ routinely operates a ski training camp.
Unfortunately, FJ has just found out about a new tax that will be assessed next year on farms used as ski training camps. Upon careful reading of the law, however, he discovers that the official definition of a ski camp requires the difference between the highest and lowest hill on his property to be strictly larger than 17. Therefore, if he shortens his tallest hills and adds mass to increase the height of his shorter hills, FJ can avoid paying the tax as long as the new difference between the highest and lowest hill is at most 17.
If it costs x^2 units of money to change the height of a hill by x units, what is the minimum amount of money FJ will need to pay? FJ can change the height of a hill only once, so the total cost for each hill is the square of the difference between its original and final height. FJ is only willing to change the height of each hill by an integer amount.
农夫约翰在他的农场有N座山(1 <= N <= 1,000),每个都有0到100的整数高度。在冬天,由于这些山上积雪很多,FJ经常进行滑雪训练营。
不幸的是,FJ刚刚发现了一项新的税收,明年将对用作滑雪训练营的农场进行评估。然而,仔细阅读法律后,他发现滑雪营的官方定义要求他的财产上的最高和最低山丘之间的差异严格大于17.因此,如果他缩短他的最高山丘并增加质量为了增加他的矮山的高度,只要最高和最低山丘之间的新差异最多为17,FJ就可以避免缴纳税款。
如果以x单位改变山丘高度需要花费x ^ 2个单位的金额,那么FJ需要支付的最低金额是多少?