题目描述
Problem Description
JOI wants to buy $ N $ pencils and decides to go to a nearby stationery store.
At the stationery store, pencils are sold in sets of a certain number of pieces. Set $ X $ contains $ A $ pieces and costs $ B $ yen, while set $ Y $ contains $ C $ pieces and costs $ D $ yen.
JOI can choose either set $ X $ or set $ Y $ and buy several of the chosen set. It is not possible to buy both sets. Find the minimum amount of money needed to get at least $ N $ pencils.
Input Format
The input is given from the standard input in the following format:
$ N $ $ A $ $ B $ $ C $ $ D $
Output Format
Output the minimum amount of money JOI needs to get at least $ N $ pencils.
Sample Input and Output
Sample Input #1
10 3 100 5 180
Sample Output #1
360
Sample Input #2
6 2 200 3 300
Sample Output #2
600
Notes/Hints
Constraints
- $1 \leq N \leq 1000$
- $1 \leq A \leq 1000$
- $1 \leq B \leq 1000$
- $1 \leq C \leq 1000$
- $1 \leq D \leq 1000$
Sample Explanation 1
JOI wants to get 10 pencils. Set $ X $ contains 3 pieces for 100 yen, and set $ Y $ contains 5 pieces for 180 yen. If set $ X $ is chosen, 4 sets are needed, which costs 400 yen. If set $ Y $ is chosen, 2 sets are needed, which costs 360 yen. Therefore, the minimum amount needed is the smaller of 400 yen and 360 yen, which is 360 yen.
Sample Explanation 2
In this case, both choosing set $ X $ and choosing set $ Y $ require 600 yen. The minimum amount needed is 600 yen.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分