input이 다음과 같음
첫째줄 : 예산 키보드수 드라이브수
둘째줄 : 키보드
셋째줄 : 드라이브
def getMoneySpent(keyboards, drives, b):
ans = -1
for i in keyboards:
for j in drives:
if i + j <= b:
ans = max(ans, i + j)
return ans
b = 10
keyboards = [3,1]
drives = [5,2,8]
print(getMoneySpent(keyboards, drives, b))
#!/bin/python3
import os
import sys
#
# Complete the getMoneySpent function below.
#
def getMoneySpent(keyboards, drives, b):
ans = -1
for i in keyboards:
for j in drives:
if i + j <= b:
ans = max(ans, i + j)
return ans
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
bnm = input().split()
b = int(bnm[0])
n = int(bnm[1])
m = int(bnm[2])
keyboards = list(map(int, input().rstrip().split()))
drives = list(map(int, input().rstrip().split()))
#
# The maximum amount of money she can spend on a keyboard and USB drive, or -1 if she can't purchase both items
#
moneySpent = getMoneySpent(keyboards, drives, b)
fptr.write(str(moneySpent) + '\n')
fptr.close()