#P6196. [EER1] 代价
[EER1] 代价
Description
You are given a sequence of length , where the st number and the nd number are fixed as . Each time, you may choose a number in the middle of the sequence and delete it (it cannot be the first or the last). The cost of deleting the number at position is . You need to perform this operation until no more operations are possible. Find the minimum total cost.
Input Format
The first line contains a positive integer .
The second line contains positive integers, where the -th number represents .
Output Format
Output one positive integer in one line, which is the minimum total cost.
3
1 2 3
9
4
19 26 8 17
846
6
1 1 1 1 1 1
6
Hint
Explanation for Sample 1:
First delete , the cost is , then delete , the cost is , then delete , the cost is .
The total cost is .
This problem uses bundled testdata.
Constraints: For of the test points, , .
This problem has subtasks. The score and constraints for each subtask are as follows:
Subtask ( point): .
Subtask ( points): .
Subtask ( points): .
Subtask ( points): .
Subtask ( points): .
Subtask ( points): no special constraints.
Special Thanks
idea: smrsky
solu: CYJian
data: iostream
Translated by ChatGPT 5
京公网安备 11011102002149号