PROBLEM LINK:
Setter: soumyadeep_21
Testers: tabr, tejas10p
Editorialist: hrishik85
DIFFICULTY:
775
PREREQUISITES:
None
PROBLEM:
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.
EXPLANATION:
Chef needs at least K lamps red.
The remaining (N-K) lamps can be red or blue.
Also - as per the constraints K \leq N
Hence the minimum amount to pay = (K \times X) + (N - K) \times (min (X,Y))
TIME COMPLEXITY:
Time complexity is O(1).
SOLUTION:
Editorialist's Solution
t=int(input())
for _ in range(t):
N,K,X,Y = map(int,input().split())
print(K*X + (N-K)*(min(X,Y)))