P27226 [AtCoder] Water Rate
普及
题目描述

Problem Description

JOI-kun lives in an area with two water companies, Company $ X $ and Company $ Y $. The monthly water rates for these two companies are determined based on the monthly water usage as follows:

  • Company $ X $: Costs $ A $ yen per liter.
  • Company $ Y $: Has a basic fee of $ B $ yen. If the usage is $ C $ liters or less, the fee is only the basic fee $ B $ yen. If the usage exceeds $ C $ liters, the basic fee $ B $ yen plus an additional fee is charged. The additional fee is $ D $ yen for each liter exceeding $ C $ liters.

JOI-kun's household uses $ P $ liters of water per month.

Determine the monthly water rate for JOI-kun's household by choosing the water company that results in the lowest cost.


Input Format

The input consists of 5 lines, each containing one integer.

The first line contains the cost per liter for Company $ X $, $ A $.
The second line contains the basic fee for Company $ Y $, $ B $.
The third line contains the usage limit for the basic fee only for Company $ Y $, $ C $.
The fourth line contains the additional cost per liter for Company $ Y $, $ D $.
The fifth line contains the monthly water usage for JOI-kun's household, $ P $.

All integers $ A, B, C, D, P $ are between 1 and 10,000 inclusive.

Output Format

Output the monthly water rate for JOI-kun's household as an integer on one line.


Sample Input and Output

Sample Input #1

9
100
20
3
10

Sample Output #1

90

Sample Input #2

8
300
100
10
250

Sample Output #2

1800

Notes/Hints

Sample Explanation 1

In Sample Input #1, JOI-kun's household uses 10 liters of water per month. - The water rate for Company $ X $ is $9 \times 10 = 90$ yen. - Since the usage is 20 liters or less, the water rate for Company $ Y $ is only the basic fee, 100 yen. JOI-kun's household chooses Company $ X $ for a lower rate of 90 yen.

Sample Explanation 2

In Sample Input #2, JOI-kun's household uses 250 liters of water per month. - The water rate for Company $ X $ is $8 \times 250 = 2000$ yen. - The usage exceeds 100 liters, with an excess of $ 250 - 100 = 150 $ liters. Therefore, the water rate for Company $ Y $ is the basic fee of 300 yen plus an additional fee of $10 \times 150 = 1500$ yen, totaling $ 300 + 1500 = 1800 $ yen. JOI-kun's household chooses Company $ Y $ for a lower rate of 1800 yen.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
9 100 20 3 10
样例输出
90