21649_TelephoneWire

2022-5-16 18:20| 发布者: Hocassian| 查看: 20| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505724574700-Problem List-采集的数据-后羿采集器.html

Pro.ID

21649

Title

Telephone Wire

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21649

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    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

    输出

    Description

    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.

    Input

    * Line 1: Two space-separated integers: N and C

    * Lines 2..N+1: Line i+1 contains a single integer: heighti

    Output

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

    Sample Input

    5 2
    2
    3
    5
    1
    4

    Sample Output

    15

    Source

    样例输入

    5 2
    2
    3
    5
    1
    4

    样例输出

    15

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部