-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeliveryMan.py
33 lines (31 loc) · 963 Bytes
/
DeliveryMan.py
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
def deliveryMan(n, x, y, a, b):
sum = 0
differences = dict()
for i in range(n):
if abs(a[i] - b[i]) in differences.keys():
differences[abs(a[i] - b[i])].append(i)
else:
differences[abs(a[i] - b[i])] = [i]
for d in sorted(differences.keys(), reverse=True):
for i in differences[d]:
if a[i] > b[i]:
if x > 0:
sum += a[i]
x -= 1
else:
sum += b[i]
y -= 1
else:
if y > 0:
sum += b[i]
y -= 1
else:
sum += a[i]
x -= 1
return sum
if __name__ == '__main__':
N, X, Y = map(int, input().strip().split())
A = list(map(int, input().strip().split()))
B = list(map(int, input().strip().split()))
res = deliveryMan(N, X, Y, A, B)
print(res)