## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

# [Solution] Buy Lamps CodeChef Solution

An electronics shop sells red and blue lamps. A red lamp costs $X$ rupees and a blue lamp costs $Y$ rupees.

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

### Input Format

• The first line of input will contain a single integer $T$, denoting the number of test cases.
Solution Click Below:-  👉
👇👇👇👇👇

• Each test case consists of a single line containing four space-separated integers $N,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

Passes for Fair CodeChef Solution

Fill Candies CodeChef Solution

Make Palindrome 2 CodeChef Solution

Fill The Grid CodeChef Solution

Positive array CodeChef Solution

Strict Permutation CodeChef Solution

buy $N$ lamps such that at least $K$ of the lamps bought are red.

### Constraints

• $1\le T\le {10}^{3}$
• $1\le N\le {10}^{8}$
• $0\le K\le N$
• $1\le X,Y\le 10$