-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathElectronics Shop.py
More file actions
41 lines (28 loc) · 870 Bytes
/
Electronics Shop.py
File metadata and controls
41 lines (28 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'''
Problem Statement: https://www.hackerrank.com/challenges/electronics-shop/problem
@Coded by TSG,2020
'''
import os
import sys
#
# Complete the getMoneySpent function below.
#
def getMoneySpent(keyboards, drives, b):
#
# Write your code here.
#
return max([sum([x,y]) for x in keyboards for y in drives if sum([x,y]) <= b]+[-1])
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()