Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: Telephone Wire
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 height ≤ 100). The new wire will connect the tops of each pair of adjacent poles and will incur a penalty cost _{i}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 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: 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 |

[Submit] [Go Back] [Status] [Discuss]

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di

Any problem, Please Contact Administrator