Buy Masks solution codechef

Buy Masks solution codechef


Click here

You go to a shop to buy masks in this pandemic.
Now, there are 3 different types of packets of mask

  • A packet of 10 masks
  • A packet of 5 masks
  • A packet of 1 mask

You are given the costs of each packet. A packet of 10 masks costs Rs. XX, a packet of 5 masks costs Rs. YY and a packet of 1 mask costs Rs. ZZ.

You need to find the minimum sum of rupees you need to pay to buy a total of exactly NN masks from the shop.

NOTE: You can buy any number of each type of packet (can be 0).

Input: Buy Masks solution codechef

  • First line will contain TT, number of testcases. Then the testcases follow.
  • Each testcase contains of a single line of input, four integers N,X,Y,ZN,X,Y,Z.

Output: Buy Masks solution codechef

For each testcase, output in a single line minimum Rupees you need to pay to buy NN masks.

Constraints Buy Masks solution codechef

  • 1T1051≤T≤105
  • 1N,X,Y,Z1061≤N,X,Y,Z≤106

Sample Input: Buy Masks solution codechef

17 10 10 3
19 30 10 1

Sample Output:



Test case 1: He will buy 1 packet of 10 masks (cost = Rs 1010), 1 packet of 5 masks (cost = Rs. 1010) and 2 packets of 1 mask (cost = Rs. 66).
Total cost = 10 + 10 + 6 = Rs. 26


Click here

Buy Masks solution codechef The Maths Lock solution codechef Minimum Adjacent Swaps to Reach the Kth Smallest Number Minimum Interval to Include Each Query

Codechef is an platform built to programmers compete against others in the community and to improve their knowledge by facing various challenges. Challenges are categorised on the basis of their difficulty level , if your rating is above 2000 you are in top tier i.e, Division 3 and if your rating is between 2000 and 1600 you will be in tier 2 i.e, Division 3 and if your rating is below that you will be in lowest tier i.e, Division 3. You can improve your rating by successful submission with minimum penalty.


Also Read : Neenade Naa song lyrics with English Translation

Leave a Comment