题目描述
Problem Description
You have encountered a group of monsters. The group consists of $ N $ types of monsters, and there are $ A_i $ monsters of the $ i $-th type.
You have decided to use the following two skills to defeat all the monsters:
- Skill $ 1 $: Consumes $ X $ MP. You can choose up to $ K $ monsters to defeat. However, all chosen monsters must be of the same type.
- Skill $ 2 $: Consumes $ Y $ MP. You can choose up to $ K $ monsters to defeat. However, all chosen monsters must be of different types.
Find the minimum amount of MP required to defeat all the monsters.
Input Format
The input is given from the standard input in the following format:
$ N $ $ K $ $ X $ $ Y $ $ A_1 $ $ A_2 $ $\cdots$ $ A_N $
Output Format
Output the answer in one line.
Sample Input and Output
Sample Input #1
5 2
10 15
1 1 1 1 2
Sample Output #1
40
Sample Input #2
5 2
15 10
1 1 1 1 2
Sample Output #2
30
Sample Input #3
5 2
10 25
1 1 1 1 2
Sample Output #3
50
Notes/Hints
Constraints
- All inputs are integers.
- $1 \leq K \leq N \leq 10^5$
- $1 \leq X, Y \leq 10^5$
- $1 \leq A_i \leq 10^5$
Sample Explanation 1
There is 1 monster each of types 1 to 4, and 2 monsters of type 5. You can defeat all monsters with 40 MP by using the skills as follows:
- Use Skill $ 2 $ on monsters of types 1 and 2. Consumes 15 MP.
- Use Skill $ 2 $ on monsters of types 3 and 4. Consumes 15 MP.
- Use Skill $ 1 $ on the 2 monsters of type 5. Consumes 10 MP.
This is the minimum MP consumption to defeat all monsters, so the answer is 40.
Sample Explanation 2
You can defeat all monsters with 30 MP by using the skills as follows:
- Use Skill $ 2 $ on monsters of types 1 and 2. Consumes 10 MP.
- Use Skill $ 2 $ on monsters of types 3 and 5. Consumes 10 MP.
- Use Skill $ 2 $ on monsters of types 4 and 5. Consumes 10 MP.
This is the minimum MP consumption to defeat all monsters, so the answer is 30.
Sample Explanation 3
You can defeat all monsters with 50 MP by using the skills as follows:
- Use Skill $ 1 $ on the monster of type 1. Consumes 10 MP.
- Use Skill $ 1 $ on the monster of type 2. Consumes 10 MP.
- Use Skill $ 1 $ on the monster of type 3. Consumes 10 MP.
- Use Skill $ 1 $ on the monster of type 4. Consumes 10 MP.
- Use Skill $ 1 $ on the 2 monsters of type 5. Consumes 10 MP.
This is the minimum MP consumption to defeat all monsters, so the answer is 50.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分