#P4393. [BalticOI 2007] Sequence 序列问题
[BalticOI 2007] Sequence 序列问题
Description
Given a sequence , we perform an operation that replaces the two elements and with a single element , producing a new sequence shorter than the original. The cost of this operation is . After performing this operation times, we obtain a sequence of length .
Our task is to compute the sequence of operations with the minimum total cost to turn the given sequence into a sequence of length .
Input Format
The first line contains an integer (), the length of the given sequence.
The next lines each contain an integer (), the elements of the sequence.
Output Format
Output a single line with one integer: the minimum total cost to reduce the sequence to a single element.
3
1
2
3
5
Hint
- For of the testdata, .
- For of the testdata, .
- For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号