adplus-dvertising

Buy Lamps CodeChef Solution

We Are Discuss About CODECHEF SOLUTION

Buy Lamps CodeChef Solution

Buy Lamps CodeChef Solution

An electronics shop sells red and blue lamps. A red lamp costs XX rupees and a blue lamp costs YY rupees.

Chef is going to buy exactly NN lamps from this shop. Find the minimum amount of money Chef needs to pay such that at least KK of the lamps bought are red.

Input Format

  • The first line of input will contain a single integer¬†TT, denoting the number of test cases.
  • Each test case consists of a single line containing four space-separated integers¬†N,K,X,YN,K,X,Y.

Output Format

For each test case, output on a new line the minimum amount of money Chef needs to pay in order to buy NN lamps such that at least KK of the lamps bought are red.

Buy Lamps CodeChef Solution

Constraints

  • 1‚ȧT‚ȧ1031‚ȧT‚ȧ103
  • 1‚ȧN‚ȧ1081‚ȧN‚ȧ108
  • 0‚ȧK‚ȧN0‚ȧK‚ȧN
  • 1‚ȧX,Y‚ȧ101‚ȧX,Y‚ȧ10

Sample Input 1 

4
2 2 5 1
4 1 3 1
3 0 4 7
5 2 3 4

Sample Output 1 

10
6
12
15

Explanation

Buy Lamps CodeChef Solution

Test case¬†11:¬†Chef buys¬†22¬†red lamps with¬†2‚čÖ5=102‚čÖ5=10¬†rupees.

Test case¬†22:¬†Chef buys¬†11¬†red lamp and¬†33¬†blue lamps with¬†1‚čÖ3+3‚čÖ1=61‚čÖ3+3‚čÖ1=6¬†rupees.

Test case¬†33:¬†Chef buys¬†33¬†red lamps with¬†3‚čÖ4=123‚čÖ4=12¬†rupees.

SOLUTION

Buy Lamps CodeChef Solution

SOLUTION

Buy Lamps CodeChef Solution

SOLUTION

Yhaa You have done it but next? if YOU Want to Get Others Please Visit Here ScishowEngineer   Then Follow US HERE and Join Telegram.

If You Want To Learn Something New Then Visit Our Official Channel YOUTUBE

Related Posts

2 thoughts on “Buy Lamps CodeChef Solution

Leave a Reply

Your email address will not be published.