#P17457. [GESP202609 六级] 数组划分
[GESP202609 六级] 数组划分
Problem Description
You are given an array consisting of integers.
You need to partition array into several non-empty contiguous subsegments. For any subsegment obtained by the partition, its deviation value is defined as the square of the sum of the integers in that subsegment. The deviation value of a partition plan is defined as the sum of the deviation values of all subsegments.
You need to minimize the deviation value of the partition plan.
Formally, you can partition into several non-empty contiguous subsegments such that , where denotes concatenation of arrays. For , let contain integers. You need to minimize $\sum_{i=1}^{k}\left(\sum_{j=1}^{m_i}a_j^{(i)}\right)^2$.
Input Format
The first line contains a positive integer , representing the length of array .
The second line contains integers , representing array .
Output Format
One line containing one integer, representing the minimum possible deviation value of the partition plan.
4
1 2 -3 4
6
6
-1 -1 4 -5 -1 4
0
Hint
For of the test points, it is guaranteed that .
For all test points, it is guaranteed that and .
Translated by ChatGPT 5