Water Bill
Time limit1sMemory limit256 MB
Compute the bills of companies X and Y from the given usage and output the cheaper one.
- Level
Easy1 of 10
- Topics
- Implementation, Math
- Solved
- No attempts yet
Problem
The area where JOI lives has two water companies, company X and company Y. Each company sets the monthly bill from the amount of water used.
- Company X: yen per liter.
- Company Y: the base fee is yen. If the usage is at most liters, only the base fee is charged. If the usage is more than liters, an extra fee is added to the base fee of yen: yen for each liter above .
JOI's house uses liters of water in a month.
JOI picks the company that makes the bill as cheap as possible. Find the monthly water bill of JOI's house.
Input
The input has 5 lines, one integer per line.
- The first line has , the per-liter charge of company X.
- The second line has , the base fee of company Y.
- The third line has , the usage limit up to which company Y charges only the base fee.
- The fourth line has , the per-liter extra fee of company Y.
- The fifth line has , the amount of water JOI's house uses in a month.
, , , , and are integers between 1 and 10000, inclusive.
Output
Print the monthly water bill of JOI's house on the first line.
Hint
In the first example the usage is 10 liters.
- The bill of company X is yen.
- The usage is at most 20 liters, so the bill of company Y is the base fee, 100 yen.
Company X is cheaper, so the answer is 90 yen.
In the second example the usage is 250 liters.
- The bill of company X is yen.
- The usage is above 100 liters, so the excess is liters. The bill of company Y is the base fee of 300 yen plus an extra fee of yen, which is yen.
Company Y is cheaper, so the answer is 1800 yen.