当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3612:Telephone Wire

题目描述

Farmer John's cows are getting restless about their poor telephone service; they want FJ to replace the old telephone wire with new, more efficient wire. The new wiring will utilize N (2 ≤ N ≤ 100,000) already-installed telephone poles, each with some heighti meters (1 ≤ heighti ≤ 100). The new wire will connect the tops of each pair of adjacent poles and will incur a penalty cost C × the two poles' height difference for each section of wire where the poles are of different heights (1 ≤ C ≤ 100). The poles, of course, are in a certain sequence and can not be moved.

Farmer John figures that if he makes some poles taller he can reduce his penalties, though with some other additional cost. He can add an integer X number of meters to a pole at a cost of X2.

Help Farmer John determine the cheapest combination of growing pole heights and connecting wire so that the cows can get their new and improved service.

输入解释

* Line 1: Two space-separated integers: N and C
* Lines 2..N+1: Line i+1 contains a single integer: heighti

输出解释

* Line 1: The minimum total amount of money that it will cost Farmer John to attach the new telephone wire.

输入样例
5 2
2
3
5
1
4
输出样例
15

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3612

最后修改于 2020-10-29T07:06:08+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536