Toukir is new in Dhaka and he just arrived today. He got a chance to study at Notre Dame College. After a full day bus journey and arranging his mess room, he now becomes thirsty. You know that, there is a lack of drinking water in Dhaka and his mess water tank is also empty. So he will go to the market to buy N liter bottled water. Before going to the market, he wants to calculate how much money he needs. Because if all the money is spent, who will give him money! Note that, there is only 1 liter and 2 liter water bottles are available to buy in the market. He will either buy all 1 liter bottles
or buy all 2 liter bottles
. But if the number of bottles purchased is more than 5, then he will need a rickshaw
to bring them. Now if the price of 1 liter water bottles is A Taka, the price of 2 liters water bottles is B Taka and the rickshaw fare from Toukir's mess to the market is P Taka, can you tell the minimum amount of money Toukir needs to go with to the market?
There will be given the value of N (1 <= N <= 100) in the first line as input. In the second or last line there will be given the values of A, B (1 < A, B <= 1000) and P (P <= 50) as input.
Calculate the minimum amount of money Toukir needs to go with to the market and print it.
Input | Output |
---|---|
9 50 40 8 | 458 |
Explanation: Because he is going to buy 9 liters of water then he will buy all 1 liter bottles. So minimum 9 × 50 = 450 + 8 = 458 tk should be needed. (Bottles > 5) নমুনার ব্যাখ্যা: যেহেতু সে ৯ লিটার পানি কিনবে তাই সে সব ১ লিটারের বোতল কিনবে। তাই সর্বনিম্ন ৯ x ৫০ = ৪৫০ + ৮ = ৪৫৮ টাকা নিয়ে যেতে হবে। (বোতল > ৫) |
Input | Output |
---|---|
10 50 80 10 | 400 |
Input | Output |
---|---|
10 90 190 50 | 950 |
Problemsetter: Mushfiqur Rahman (mdvirus)