|  | 
|  | 1 | +#!/bin/python3 | 
|  | 2 | + | 
|  | 3 | +import os | 
|  | 4 | +import sys | 
|  | 5 | + | 
|  | 6 | +# | 
|  | 7 | +# Complete the getMoneySpent function below. | 
|  | 8 | +# | 
|  | 9 | +def getMoneySpent(keyboards, drives, b): | 
|  | 10 | + # | 
|  | 11 | + # Write your code here. | 
|  | 12 | + # | 
|  | 13 | + ls = [] | 
|  | 14 | + for i in range(len(keyboards)): | 
|  | 15 | + for j in range(len(drives)): | 
|  | 16 | + total = keyboards[i]+drives[j] | 
|  | 17 | + if b>=total: | 
|  | 18 | + ls.append(total) | 
|  | 19 | + try: | 
|  | 20 | + jo = max(ls) | 
|  | 21 | + if jo<=b: | 
|  | 22 | + return jo | 
|  | 23 | + except: | 
|  | 24 | + return -1 | 
|  | 25 | + | 
|  | 26 | +if __name__ == '__main__': | 
|  | 27 | + fptr = open(os.environ['OUTPUT_PATH'], 'w') | 
|  | 28 | + | 
|  | 29 | + bnm = input().split() | 
|  | 30 | + | 
|  | 31 | + b = int(bnm[0]) | 
|  | 32 | + | 
|  | 33 | + n = int(bnm[1]) | 
|  | 34 | + | 
|  | 35 | + m = int(bnm[2]) | 
|  | 36 | + | 
|  | 37 | + keyboards = list(map(int, input().rstrip().split())) | 
|  | 38 | + | 
|  | 39 | + drives = list(map(int, input().rstrip().split())) | 
|  | 40 | + | 
|  | 41 | + # | 
|  | 42 | + # The maximum amount of money she can spend on a keyboard and USB drive, or -1 if she can't purchase both items | 
|  | 43 | + # | 
|  | 44 | + | 
|  | 45 | + moneySpent = getMoneySpent(keyboards, drives, b) | 
|  | 46 | + | 
|  | 47 | + fptr.write(str(moneySpent) + '\n') | 
|  | 48 | + | 
|  | 49 | + fptr.close() | 
0 commit comments