题目描述
Problem Description
Aya is moving bricks at a construction site. She has $n$ bricks and needs to divide them equally into two groups to be transported to different destinations. Note that the bricks cannot be cut into halves.
Aya can choose to move the bricks one by one, which requires $a$ units of energy for each brick. Alternatively, she can load the bricks onto a cart that can hold up to $k$ bricks (the cart does not need to be fully loaded) and then push the cart to the destination, which requires $b$ units of energy for the entire process. Aya can freely choose the method of moving the bricks. For example, she can move some bricks one by one and then use the cart for the rest.
Aya wants to know the minimum amount of energy required for this process.
Input Format
The input consists of four positive integers $n, a, k, b$, which represent the number of bricks, the energy required to move one brick, the capacity of the cart, and the energy required to move the cart, respectively.
Output Format
Output a single integer, which represents the minimum amount of energy required. If it is impossible to divide the bricks equally into two groups, output $-1$.
Sample Input and Output
Sample Input #1
12 3 2 2
Sample Output #1
12
Sample Input #2
15 3 2 2
Sample Output #2
-1
Notes
[Sample Explanation]
For Sample #1, dividing the bricks equally results in 6 bricks per group. Using the cart, which can carry 2 bricks at a time and costs 2 units of energy, is more efficient than moving bricks one by one. Therefore, Aya chooses to use the cart three times, costing 6 units of energy. Since there are two groups of bricks, the total energy cost is 12 units.
[Data Range]
For all data, $1 \leq n, a, k, b \leq 10^6$. Please note the data range.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分