-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtadelive.py
More file actions
29 lines (28 loc) · 767 Bytes
/
tadelive.py
File metadata and controls
29 lines (28 loc) · 767 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
N, X, Y = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
# Sorting A,B by their difference in descending order.
# The intent is to reduce loss.
# So, the orders with the hughest losses will be handled first
tipSortedByDiffAmt = sorted(list(zip(A,B)), reverse=True, key=lambda x: abs(x[0]-x[1]))
aOrdCnt = 0
bOrdCnt = 0
answer = 0
for t in tipSortedByDiffAmt:
if t[0] >= t[1]:
if aOrdCnt < X:
aOrdCnt+=1
answer+=t[0]
else:
bOrdCnt+=1
answer+=t[1]
elif t[1] >= t[0]:
if bOrdCnt < Y:
bOrdCnt+=1
answer+=t[1]
else:
aOrdCnt+=1
answer+=t[0]
else:
break
print (answer)