#P11958. 「ZHQOI R1」划分
「ZHQOI R1」划分
Description
You are given array . You need to split it into some subsegments (so every element is included in exactly one subsegment).
The weight of a subsegment is equal to . The weight of a partition is a total weight of all its segments.
Find the partition of minimal weight.
Input Format
The first line contains an integer — the length of the array .
The second line contains integers — the array .
Output Format
Print a single integer — the minimal weight among all possible partitions.
4
-1 2 -1 2
-4
6
-3 4 -9 1 2 4
-48
Hint
The optimal partition in the first example is next: .
The optimal partition in the second example is next: .
Constraints
This problem uses subtask scoring.
For of the data, , .
| Subtask | Additional Constraints | Score | |
|---|---|---|---|
| None | |||
| All have the same sign | |||
| are randomly generated | |||
| None | |||
| Number of negatives in is less than | |||
| None |
京公网安备 11011102002149号