题目: https://www.luogu.org/problemnew/show/P2885 由于把每一根电线杆增加多少高度不确定,所以很难直接通过某种方法算出答案,考虑动态规划. 状态:f [ i ] [ j ]表示当第i根电线杆的高度为j时的最小代价和. 转移:当前电线杆的高度只会影响它下一个电线杆的高度,所以就是用前一维的答案来更新后一维.在计算第i根电线杆和第i-1根电线杆时需要计算三部分答案:1.将第i根电线杆增加到j高度的代价 ( j - h [ i ])*(j - h [ i ]…
题目描述 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 wit…