There are three types of fruits T1,T2, and T3 in a shop. Each fruit of type T1,T2, and T3 gives energy 2,3, and 5 respectively.
The number of fruits of type T1,T2, and T3 are Cnt1,Cnt2, and Cnt3 respectively and each fruit cost Cost1,Cost2, and Cost3 respectively.
You want to get a total of S energy by buying some of the fruits, but you want to spend as less as possible.
So, find the minimum amount you need to spend.
Print "-1" if the answer does not exist.
Input format
- First line : S represents total amount of energy.
- Second line : Three space-separated integers Cnt1, Cnt2, and Cnt3
- Third line : Three space-separated integers Cost1, Cost2, and Cost3
Output format
Print the answer.
Constraints
1≤S≤3×104
1≤Cnti≤7×103 for 1≤i≤3
1≤Costi≤7×103 for 1≤i≤3
We can make a total of energy 10 by two ways :-
Case 1 :- Buying two T1, two T2. So this will cost 20.
Case 2 :- Buying one T1, one T2, one T3, So this will cost 30.
So, the minimum is 20.