int keyboards[n]: the keyboard prices array , size is n
int drives[m]: the drive prices array , size is m
int b: the budget
int: the maximum that can be spent, or -1 if it is not possible to buy both items
def getMoneySpent(keyboards, drives, b):
result = 0
keyboards.sort()
drives.sort()
if(keyboards[0]+drives[0]>b):
return -1
for i in range(len(keyboards)):
for j in range(len(drives)):
if(keyboards[i]+drives[j]<=b and result<= keyboards[i]+drives[j]):
result = keyboards[i]+drives[j]
return result