#P6622. [省选联考 2020 A/B 卷] 信号传递
[省选联考 2020 A/B 卷] 信号传递
Description
On a road, there are signal stations arranged from left to right. Initially, they are numbered from left to right, and the distance between any two adjacent stations is unit.
Each signal station can only transmit a signal to any station on its right (called normal transmission). It takes unit of time per unit distance.
At the far left of the road, there is a control tower. It is to the left of the leftmost signal station, with a distance of unit between them. The control tower can transmit signals bidirectionally with any signal station (called special transmission), but it takes units of time per unit distance.
Given a signal transmission sequence of length , the transmission rules are:
- There are transmissions in total. In the -th transmission, the signal is sent from station to station .
- If station is to the right of station , use normal transmission, sending directly from to .
- If station is to the left of station , use special transmission: the signal is sent from to the control tower, and then from the control tower to .
- If , no transmission is needed.
Aki, as a chief engineer, can swap the positions of any two signal stations any number of times, i.e., he can reorder the signal stations. This will change the total time consumed by . Now Aki wants to know: after reordering the signal stations, what is the minimum possible total transmission time for ?
Input Format
The first line contains three integers , representing the length of the signal transmission sequence , the number of signal stations, and the time cost per unit distance for special transmission.
The second line contains integers, where the -th integer denotes .
Output Format
Output one integer in a single line, representing the answer.
3 3 1
1 2 3
2
4 3 1
1 2 3 1
6
Hint
[Sample Explanation ]
Keeping the signal station order unchanged, normal transmission is used twice, and the time cost is .
[Sample Explanation ]
For the permutation , the transmission time is .
For the permutation , the transmission time is .
For the permutation , the transmission time is .
For the permutation , the transmission time is .
For the permutation , the transmission time is .
For the permutation , the transmission time is .
[Constraints]
of the testdata: .
of the testdata: .
of the testdata: .
of the testdata: .
of the testdata: , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号