#Q193. 「一本通 5.6 练习 4」打印文章
「一本通 5.6 练习 4」打印文章
Description
Original Problem from: HDU 3507
Given words, each with a non-negative weight , they are to be divided into consecutive segments. The cost of each segment is the square of the sum of the weights of the words in the segment plus a constant , i.e., . The goal is to find an optimal segmentation that minimizes the total cost.
Input Format
The input contains multiple test cases. For each test case:
The first line contains two integers and .
The second line contains integers.
Output Format
Output a single integer representing the minimum total cost.
Sample 1
5 5
5 9 5 7 5
230
Constraints & Notes
For all test cases, .