Buy Lamps problem

Hello, I am confused as to how the following is a solution to this problem:

for i in range(int(input())):
    N,K,X,Y=map(int,input().split())
    if X>Y :
        money=(K*X)+(N-K)*Y
    else:
        money=N*X
    print(money)

But this wouldn’t be:

for i in range(int(input())):
    n,k,x,y = map(int,input().split())
    bluelamps = n-k
    redlamps = k
    costb = bluelamps*y
    costr = redlamps*x
    print(costb+costr)

Can some please explain in beginner terms?