Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Water Bottle Buying

By mdvirus · Limits 500ms, 256 MB

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.


50 40 8

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 ৫০ = ৪৫০ + ৮ = ৪৫৮ টাকা নিয়ে যেতে হবে। (বোতল > ৫)

50 80 10
90 190 50

Problemsetter: Mushfiqur Rahman (mdvirus)



    79% Solution Ratio

    theunownEarliest, 3M ago

    theunownFastest, 0.0s

    theunownLightest, 0 B

    mdgaziur001Shortest, 179B


    Login to submit

    Related Contests

    ATOEB: কোডshock_ 2019 Ended at 2019-12-19 11:30:00 +0000 UTC