#P6622. [省选联考 2020 A/B 卷] 信号传递

[省选联考 2020 A/B 卷] 信号传递

Description

On a road, there are mm signal stations arranged from left to right. Initially, they are numbered 1,2,,m1,2,\dots,m from left to right, and the distance between any two adjacent stations is 11 unit.

Each signal station can only transmit a signal to any station on its right (called normal transmission). It takes 11 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 11 unit between them. The control tower can transmit signals bidirectionally with any signal station (called special transmission), but it takes kk units of time per unit distance.

Given a signal transmission sequence SS of length nn, the transmission rules are:

  1. There are n1n-1 transmissions in total. In the ii-th transmission, the signal is sent from station SiS_i to station Si+1S_{i+1}.
  2. If station Si+1S_{i+1} is to the right of station SiS_i, use normal transmission, sending directly from SiS_i to Si+1S_{i+1}.
  3. If station Si+1S_{i+1} is to the left of station SiS_i, use special transmission: the signal is sent from SiS_i to the control tower, and then from the control tower to Si+1S_{i+1}.
  4. If Si=Si+1S_i=S_{i+1}, 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 SS. Now Aki wants to know: after reordering the signal stations, what is the minimum possible total transmission time for SS?

Input Format

The first line contains three integers n,m,kn,m,k, representing the length of the signal transmission sequence SS, the number of signal stations, and the time cost per unit distance for special transmission.

The second line contains nn integers, where the ii-th integer denotes SiS_i.

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 11]

Keeping the signal station order unchanged, normal transmission is used twice, and the time cost is 1+1=21+1=2.

[Sample Explanation 22]

For the permutation 1,2,31,2,3, the transmission time is 1+1+(3×1+1×1)=61+1+(3\times 1+1\times 1)=6.

For the permutation 1,3,21,3,2, the transmission time is 2+(3×1+2×1)+(2×1+1×1)=102+(3\times 1+2\times 1)+(2\times 1+1\times 1)=10.

For the permutation 2,1,32,1,3, the transmission time is (2×1+1×1)+2+(3×1+2×1)=10(2\times 1+1\times 1)+2+(3\times 1+2\times 1)=10.

For the permutation 2,3,12,3,1, the transmission time is (3×1+1×1)+1+1=6(3\times 1+1\times 1)+1+1=6.

For the permutation 3,1,23,1,2, the transmission time is 1+(3×1+1×1)+1=61+(3\times 1+1\times 1)+1=6.

For the permutation 3,2,13,2,1, the transmission time is (3×1+2×1)+(2×1+1×1)+2=10(3\times 1+2\times 1)+(2\times 1+1\times 1)+2=10.

[Constraints]

30%30\% of the testdata: m8,n100m\leq 8, n\leq 100.

60%60\% of the testdata: m20m\leq 20.

70%70\% of the testdata: m21m\leq 21.

80%80\% of the testdata: m22m\leq 22.

100%100\% of the testdata: 2m232\leq m\leq 23, 2n1052\leq n\leq 10^5, 1k1001\leq k\leq 100, 1Sim1\leq S_i\leq m.

Translated by ChatGPT 5