9134: ABC331 —— B - Buy One Carton of Milk
[Creator : ]
Description
A supermarket sells egg packs.
A pack of $6$ eggs costs $S$ yen, a pack of $8$ eggs costs $M$ yen, and a pack of $12$ eggs costs $L$ yen.
When you can buy any number of each pack, find the minimum amount of money required to purchase at least $N$ eggs.
A pack of $6$ eggs costs $S$ yen, a pack of $8$ eggs costs $M$ yen, and a pack of $12$ eggs costs $L$ yen.
When you can buy any number of each pack, find the minimum amount of money required to purchase at least $N$ eggs.
Input
The input is given from Standard Input in the following format:
```
$N$ $S$ $M$ $L$
```
```
$N$ $S$ $M$ $L$
```
Output
Print the answer.
Constraints
- $1 \leq N \leq 100$
- $1 \leq S,M,L \leq 10^4$
- All input values are integers.
- $1 \leq S,M,L \leq 10^4$
- All input values are integers.
Sample 1 Input
16 120 150 200
Sample 1 Output
300
It is optimal to buy two 8-egg packs.
Sample 2 Input
10 100 50 10
Sample 2 Output
10
It is optimal to buy one 12-egg pack.
Sample 3 Input
99 600 800 1200
Sample 3 Output
10000
It is optimal to buy five 8-egg packs and five 12-egg packs.
HINT
相同题目:ABC331。