LearnPy Hub
← Arena
EasyRating 1000

Gift Costs

You need b black and w white gifts. A black gift costs bc, a white costs wc, and any gift can be repainted to the other colour for z. Print the lowest total cost.

Input

Five integers b w bc wc z.

Output

One integer.

Sample 1

Input
10 10 1 1 1
Output
20

Sample 2

Input
5 9 2 3 4
Output
37
solution.py
Output appears here
Gift Costs · Python Arena problem · LearnPy Hub