#P5331. [SNOI2019] 通信
[SNOI2019] 通信
Description
There are sentry stations arranged in a line. The frequency band of station is .
Each station needs to choose one of the following two options:
- Connect directly to the control center, with a cost of .
- Connect to some previous station (), with a cost of .
Each station can be connected by at most one later station.
Please find the minimum possible total cost.
Input Format
The first line contains two non-negative integers , representing the number of sentry stations and the cost to connect to the control center.
The second line contains non-negative integers separated by spaces, representing the frequency band of each station in order.
Output Format
Output one line containing one non-negative integer, representing the answer.
6 7
8 4 6 1 3 0
23
8 4
0 4 2 6 1 5 3 7
18
Hint
For all testdata, , .
For of the testdata, .
For another of the testdata, .
For another of the testdata, , , .
For another of the testdata, .
For another of the testdata, .
For the remaining of the testdata, there are no special constraints.
Translated by ChatGPT 5
京公网安备 11011102002149号