We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Your solution SHOULD be in the Editorial!
This is how it could look like in Python 2:
#!/bin/pythonimportsysdefgetMoneySpent(keyboards,drives,n,m,s):keyboards.sort(reverse=True)drives.sort()ms=-1i=j=0whilei<n:whilej<m:ifkeyboards[i]+drives[j]>s:breakifkeyboards[i]+drives[j]>ms:ms=keyboards[i]+drives[j]j+=1i+=1returnmss,n,m=raw_input().strip().split(' ')s,n,m=[int(s),int(n),int(m)]keyboards=map(int,raw_input().strip().split(' '))drives=map(int,raw_input().strip().split(' '))# The maximum amount of money she can spend on a keyboard and USB drive, or -1 if she can't purchase both itemsmoneySpent=getMoneySpent(keyboards,drives,n,m,s)print(moneySpent)
Electronics Shop
You are viewing a single comment's thread. Return to all comments →
Your solution SHOULD be in the Editorial! This is how it could look like in Python 2: