(keyboards, drives, b)
| 24 | |
| 25 | #getMoneySpent() will return the amount required to buy the most expensive keyboard and USB drive. If not not possible returns -1. |
| 26 | def getMoneySpent(keyboards, drives, b): |
| 27 | moneyspent=-1 #maximum amount of money spent |
| 28 | drives.sort() |
| 29 | for num in keyboards: |
| 30 | price=check(drives,0,m-1,b-num,-1) #price=price of most expensive USB drive that can be bought after purchasing the keyboard of price num |
| 31 | if price==-1: |
| 32 | continue |
| 33 | exp=price+num #exp=expense after buying both the items |
| 34 | if exp>moneyspent: |
| 35 | moneyspent=exp |
| 36 | |
| 37 | return moneyspent |
| 38 | |
| 39 | |
| 40 | #input part fot the given problem |
no test coverage detected