#agc019a. [agc019_a]Ice Tea Store
[agc019_a]Ice Tea Store
Problem Statement
You've come to your favorite store Infinitesco to buy some ice tea.
The store sells ice tea in bottles of different volumes at different costs. Specifically, a -liter bottle costs yen, a -liter bottle costs yen, a -liter bottle costs yen, and a -liter bottle costs yen. The store has an infinite supply of bottles of each type.
You want to buy exactly liters of ice tea. How many yen do you have to spend?
Constraints
- All input values are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the smallest number of yen you have to spend to buy exactly liters of ice tea.
Sample Input 1
20 30 70 90
3
Sample Output 1
150
Buy one -liter bottle and two -liter bottles. You'll get liters for yen.
Sample Input 2
10000 1000 100 10
1
Sample Output 2
100
Even though a -liter bottle costs just yen, you need only liter. Thus, you have to buy a -liter bottle for yen.
Sample Input 3
10 100 1000 10000
1
Sample Output 3
40
Now it's better to buy four -liter bottles for yen.
Sample Input 4
12345678 87654321 12345678 87654321
123456789
Sample Output 4
1524157763907942