Read problems statements in Mandarin Chinese  and Russian. 

Andy and Bob are the only two delivery men of Pizza-chef store. Today, the store received N orders. 
It's known that the amount of tips may be different when handled by different delivery man. 
More specifically, if Andy takes the i^{th} order, he would be tipped A_{i} dollars and if Bob takes this order, 
the tip would be B_{i} dollars. 

They decided that they would distribute the orders among themselves to maximize the total tip money. One order will be handled by only
one person. Also, due to time constraints Andy cannot take more than X orders and Bob cannot take more than 
Y orders. It is guaranteed that X + Y is greater than or equal to N, which means that all the orders can be handled 
by either Andy or Bob.
	
Please find out the maximum possible amount of total tip money after processing all the orders.

------ Input ------ 

The first line contains three integers N, X, Y.
The second line contains N integers. The i^{th} integer represents A_{i}.
The third line contains N integers. The i^{th} integer represents B_{i}.

------ Output ------ 

Print a single integer representing the maximum tip money they would receive.

------ Constraints ------ 

All test:

$1 ≤ N ≤ 10^{5}$
$1 ≤ X, Y ≤ N; X + Y ≥ N $
$1 ≤ A_{i}, B_{i} ≤ 10^{4}$

10 points:
$1 ≤ N ≤ 20$

30 points:
$1 ≤ N ≤ 5000$
60 points:
$1 ≤ N ≤ 10^{5}$

----- Sample Input 1 ------ 
5 3 3
1 2 3 4 5
5 4 3 2 1
----- Sample Output 1 ------ 
21
----- explanation 1 ------ 
Bob will take the first three orders (or the first two) and Andy will take the rest (of course).

Source: codechef | Difficulty: MEDIUM_HARD
Tags: Sorting

Greedy algorithms


Solutions:
(n, x, y) = [int(j) for j in input().split()]
a = [int(j) for j in input().split()]
b = [int(j) for j in input().split()]
c = [(abs(i - j), i, j) for (i, j) in zip(a, b)]
c.sort(reverse=1)
ans = 0
for (i, j, k) in c:
	if x > 0 and y > 0:
		if j < k:
			ans += k
			y -= 1
		else:
			ans += j
			x -= 1
	elif x <= 0:
		ans += k
	else:
		ans += j
print(ans)


(n, x, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
diff = []
sum = 0
for i in range(n):
	diff.append((a[i] - b[i], i))
diff.sort(reverse=True)
for j in range(n):
	i = diff[j][1]
	if a[i] > b[i] and x > 0 or y < 0:
		sum += a[i]
		x -= 1
	else:
		sum += b[i]
		y -= 1
print(sum)


(N, X, Y) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
loss = []
for i in range(N):
	loss.append((abs(A[i] - B[i]), i))
loss.sort(reverse=True)
profit = 0
for i in range(N):
	k = loss[i][1]
	if A[k] > B[k] and X > 0:
		profit += A[k]
		X -= 1
	elif A[k] > B[k] and X == 0:
		profit += B[k]
	elif B[k] > A[k] and Y > 0:
		profit += B[k]
		Y -= 1
	else:
		profit += A[k]
print(profit)


while 1:
	try:
		(n, x, y) = map(int, input().split())
		A = list(map(int, input().split()))
		B = list(map(int, input().split()))
		ans = 0
		s = 0
		c = []
		for i in range(n):
			s += A[i]
			c.append(B[i] - A[i])
		c.sort(reverse=True)
		res = -1
		for i in range(y):
			s += c[i]
			if i + 1 >= n - x:
				res = max(res, s)
		print(res)
	except:
		break


(N, x, y) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
difference = []
for (i, j) in zip(A, B):
	difference.append((abs(i - j), i, j))
difference.sort(key=lambda x: x[0], reverse=True)
for i in difference:
	if i[1] >= i[2]:
		if x != 0:
			ans += i[1]
			x -= 1
		else:
			ans += i[2]
	elif y != 0:
		ans += i[2]
		y -= 1
	else:
		ans += i[2]
print(ans)


(n, x, y) = map(int, input().split())
arr = list(map(int, input().split()))
barr = list(map(int, input().split()))
mas = 0
z = [[i, abs(arr[i] - barr[i])] for i in range(n)]
z.sort(key=lambda x: x[1], reverse=True)
for i in z:
	if arr[i[0]] >= barr[i[0]]:
		if x > 0:
			mas += arr[i[0]]
			x -= 1
		else:
			mas += barr[i[0]]
			y -= 1
	elif arr[i[0]] <= barr[i[0]]:
		if y > 0:
			mas += barr[i[0]]
			y -= 1
		else:
			mas += arr[i[0]]
			x -= 1
print(mas)


(n, x, y) = map(int, input().split())
andy = [int(x) for x in input().split()]
bob = [int(x) for x in input().split()]
li = [andy[i] - bob[i] for i in range(n)]
li.sort(reverse=True)
ans = sum(bob)
for i in range(x):
	if li[i] > 0:
		ans += li[i]
print(ans)


(n, x, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
for i in range(len(a)):
	c.append([a[i], b[i]])
c.sort(key=lambda x: abs(x[0] - x[1]))
s = 0
c.reverse()
for i in range(len(a)):
	if c[i][0] > c[i][1] and x > 0:
		s += c[i][0]
		x -= 1
	elif c[i][0] < c[i][1] and y > 0:
		s += c[i][1]
		y -= 1
	elif c[i][0] < c[i][1] and y <= 0:
		s += c[i][0]
		x -= 1
	elif c[i][0] > c[i][1] and x <= 0:
		s += c[i][1]
		y -= 1
	elif c[i][0] == c[i][1] and x >= y and (x > 0):
		s += c[i][0]
		x -= 1
	elif c[i][0] == c[i][1] and y >= x and (y > 0):
		s += c[i][0]
		y -= 1
print(s)


try:
	(n, x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	jj = 0
	k = 0
	c = 0
	z = []
	for i in range(0, n):
		z.append((abs(a[i] - b[i]), i))
	z.sort(reverse=True)
	for j in range(0, n):
		i = z[j][1]
		if a[i] > b[i] and jj < x:
			c += a[i]
			jj += 1
		elif a[i] < b[i] and k < y or jj >= x:
			c += b[i]
			k += 1
		else:
			c += a[i]
			jj += 1
	print(c)
except:
	pass


(m, x, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
diff = []
for i in range(0, m):
	diff.append((abs(b[i] - a[i]), i))
sorteddiff = sorted(diff, key=lambda x: x[0], reverse=True)
t = 0
for i in range(m):
	if a[sorteddiff[i][1]] > b[sorteddiff[i][1]]:
		if x > 0:
			t += a[sorteddiff[i][1]]
			x -= 1
		else:
			t += b[sorteddiff[i][1]]
			y -= 1
	elif y > 0:
		t += b[sorteddiff[i][1]]
		y -= 1
	else:
		t += a[sorteddiff[i][1]]
		x -= 1
print(t)


(N, X, Y) = map(int, input().split())
tip1 = list(map(int, input().split()))
tip2 = list(map(int, input().split()))
diff = []
for i in range(len(tip1)):
	diff.append(tip1[i] - tip2[i])
diff.sort(reverse=1)
profit = sum(tip2)
cnt1 = 1
cnt2 = N
while cnt1 <= X and diff[cnt1 - 1] >= 0 or cnt2 > Y:
	profit += diff[cnt1 - 1]
	cnt1 += 1
	cnt2 -= 1
print(profit)


(n, x, y) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = []
c = 0
for i in range(n):
	d.append([abs(a[i] - b[i]), i])
d.sort()
d.reverse()
for i in range(n):
	k = d[i][1]
	if a[k] >= b[k]:
		if x > 0:
			c += a[k]
			x -= 1
		else:
			c += b[k]
			y -= 1
	elif y > 0:
		c += b[k]
		y -= 1
	else:
		c += a[k]
		x -= 1
print(c)


(N, X, Y) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
(loss, ans) = ([], 0)
for i in range(N):
	if A[i] > B[i]:
		loss.append((A[i] - B[i], i))
	else:
		loss.append((B[i] - A[i], i))
loss.sort(reverse=True)
for (l, idx) in loss:
	if A[idx] >= B[idx]:
		if X > 0:
			ans += A[idx]
			X -= 1
		else:
			ans += B[idx]
			Y -= 1
	elif Y > 0:
		ans += B[idx]
		Y -= 1
	else:
		ans += A[idx]
		X -= 1
print(ans)


(n, x, y) = map(int, input().split())
la = list(map(int, input().split()))
lb = list(map(int, input().split()))
d = [abs(la[i] - lb[i]) for i in range(n)]
(d, la, lb) = zip(*sorted(zip(d, la, lb)))
count = 0
(z, a) = (x, y)
mla = 0
mlb = 0
for i in range(n - 1, -1, -1):
	if la[i] > lb[i]:
		if x > 0:
			x -= 1
			count += la[i]
		else:
			y -= 1
			count += lb[i]
	elif la[i] == lb[i]:
		mla += la[i]
	elif y > 0:
		y -= 1
		count += lb[i]
	else:
		x -= 1
		count += la[i]
count = count + mla
print(count)


(n, x, y) = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
b = [int(s) for s in input().split()]
ab = []
for i in range(n):
	ab.append((a[i], b[i]))
ab.sort(key=lambda v: -abs(v[0] - v[1]))
total = 0
for (a, b) in ab:
	if y == 0 or (x != 0 and a >= b):
		total += a
		x -= 1
	else:
		total += b
		y -= 1
print(total)


(n, x, y) = map(int, input().split())
a = list(map(int, input().split()))[:n]
b = list(map(int, input().split()))[:n]
total = 0
loss = []
for i in range(0, n):
	loss.append((abs(b[i] - a[i]), i))
loss.sort(reverse=True)
for (m, n) in loss:
	if a[n] > b[n]:
		if x > 0:
			total += a[n]
			x -= 1
		else:
			total += b[n]
			y -= 1
	elif y > 0:
		total += b[n]
		y -= 1
	else:
		total += a[n]
		x -= 1
print(total)


def sol(A, B, x, y):
	diff = []
	for i in range(len(A)):
		diff.append([abs(A[i] - B[i]), i])
	diff.sort(reverse=True)
	total = 0
	for i in diff:
		idx = i[1]
		if A[idx] > B[idx]:
			if x > 0:
				total += A[idx]
				x = x - 1
			else:
				total += B[idx]
				y = y - 1
		elif y > 0:
			total += B[idx]
			y = y - 1
		else:
			total += A[idx]
			x = x - 1
	return total
(n, x, y) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
print(sol(A, B, x, y))


(n, x, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = []
c = d = sum = 0
for i in range(n):
	l.append([abs(a[i] - b[i]), i])
l.sort(reverse=True)
for i in range(n):
	key = l[i][1]
	if a[key] >= b[key]:
		if c < x:
			sum += a[key]
			c += 1
		else:
			sum += b[key]
			d += 1
	elif d < y:
		sum += b[key]
		d += 1
	else:
		sum += a[key]
		c += 1
print(sum)


(n, x, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
diff = [(a[i] - b[i], i) for i in range(n)]
diff.sort(reverse=True)
orders = 0
res = 0
for (d, i) in diff:
	if d < 0:
		if orders + y >= n:
			res += b[i]
			y -= 1
			orders += 1
			continue
	if x:
		res += a[i]
		orders += 1
		x -= 1
	else:
		res += b[i]
		orders += 1
		y -= 1
print(res)


(n, x, y) = map(int, input().split())
andy = [*map(int, input().split())]
bob = [*map(int, input().split())]
combined = [[andy[i], bob[i]] for i in range(n)]
combined.sort(key=lambda x: abs(x[0] - x[1]), reverse=True)
ans = 0
z = x + y
i = 0
while i < n:
	if combined[i][0] > combined[i][1]:
		if x > 0:
			x -= 1
			ans += combined[i][0]
		else:
			y -= 1
			ans += combined[i][1]
	elif y > 0:
		y -= 1
		ans += combined[i][1]
	else:
		x -= 1
		ans += combined[i][0]
	i += 1
print(ans)


def get_output(n, x, y, a, b, diff_arr):
	tip_sum = 0
	for j in range(n):
		ind = diff_arr[j][1]
		if a[ind] > b[ind] and x > 0:
			tip_sum += a[ind]
			x -= 1
		elif y > 0:
			tip_sum += b[ind]
			y -= 1
		else:
			tip_sum += a[ind]
			x -= 1
	return tip_sum
(n, x, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
diff_arr = []
for i in range(n):
	diff_arr.append((abs(a[i] - b[i]), i))
diff_arr.sort(reverse=True)
print(get_output(n, x, y, a, b, diff_arr))


(n, x, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = []
for i in range(n):
	if a[i] > b[i]:
		l.append((a[i] - b[i], i))
	else:
		l.append((b[i] - a[i], i))
l.sort(reverse=True)
profit = 0
for (m, n) in l:
	if a[n] > b[n]:
		if x > 0:
			profit += a[n]
			x -= 1
		else:
			profit += b[n]
			y -= 1
	elif y > 0:
		profit += b[n]
		y -= 1
	else:
		profit += a[n]
		x -= 1
print(profit)


(N, x, y) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
profit = 0
dif = []
for i in range(N):
	dif.append((abs(A[i] - B[i]), i))
dif.sort()
dif.reverse()
for i in range(N):
	if A[dif[i][1]] > B[dif[i][1]]:
		if x > 0:
			profit += A[dif[i][1]]
			x -= 1
		else:
			profit += B[dif[i][1]]
			y -= 1
	elif y > 0:
		profit += B[dif[i][1]]
		y -= 1
	else:
		profit += A[dif[i][1]]
		x -= 1
print(profit)


(N, X, Y) = map(int, input('').split())
andy = list(map(int, input('').split()))
bob = list(map(int, input('').split()))
differences = []
for i in range(len(andy)):
	differences.append((abs(andy[i] - bob[i]), i))
differences.sort(key=lambda tup: tup[0], reverse=True)
total_tip = 0
for (_, index) in differences:
	if andy[index] > bob[index] and X > 0 or Y == 0:
		X -= 1
		total_tip += andy[index]
	else:
		Y -= 1
		total_tip += bob[index]
print(total_tip)


(N, X, Y) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
loss = []
index = 0
for (i, j) in zip(l1, l2):
	loss.append([abs(i - j), index])
	index += 1
loss.sort(key=lambda x: x[0], reverse=True)
tp = 0
for i in range(N):
	index = loss[i][1]
	if l1[index] >= l2[index]:
		if X > 0:
			tp += l1[index]
			X -= 1
		else:
			tp += l2[index]
			Y -= 1
	elif Y > 0:
		tp += l2[index]
		Y -= 1
	else:
		tp += l1[index]
		X -= 1
print(tp)


try:
	(n, x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ab = []
	for i in range(n):
		ab.append((abs(a[i] - b[i]), i))
	ab.sort()
	ab.reverse()
	s = 0
	for j in range(n):
		k = ab[j][1]
		if a[k] > b[k] and x > 0:
			s = s + a[k]
			x = x - 1
		elif a[k] > b[k] and x == 0:
			s = s + b[k]
		elif b[k] > a[k] and y > 0:
			s = s + b[k]
			y = y - 1
		else:
			s = s + a[k]
	print(s)
except:
	pass


def mp(n, x, y, a, b, diff):
	pro = 0
	for j in range(n):
		i = diff[j][1]
		if a[i] > b[i] and x > 0:
			pro += a[i]
			x -= 1
		elif y > 0:
			pro += b[i]
			y -= 1
		else:
			pro += a[i]
			x -= 1
	return pro
(n, x, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
diff = []
for i in range(n):
	diff.append((abs(a[i] - b[i]), i))
diff.sort(reverse=True)
print(mp(n, x, y, a, b, diff))


(N, X, Y) = map(int, input().split())
A = []
B = []
d = []
l = []
a1 = input().split()
b1 = input().split()
for i in range(N):
	A.append(int(a1[i]))
	B.append(int(b1[i]))
	d.append([A[i] - B[i], i])
	if d[i][0] < 0:
		d[i][0] = -d[i][0]
d.sort(reverse=True)
ans = 0
for i in range(N):
	i1 = d[i][1]
	if A[i1] > B[i1]:
		if X > 0:
			X = X - 1
			ans = ans + A[i1]
		else:
			Y = Y - 1
			ans = ans + B[i1]
	elif Y > 0:
		Y = Y - 1
		ans = ans + B[i1]
	else:
		X = X - 1
		ans = ans + A[i1]
print(ans)


from math import *
from collections import *
from functools import *

def rvi():
	return [*map(int, input().split())]
for _ in range(1):
	(n, x, y) = rvi()
	a = rvi()
	b = rvi()
	c = [(abs(i - j), i, j) for (i, j) in zip(a, b)]
	c.sort(reverse=1)
	r = 0
	for (a, i, j) in c:
		if j > i:
			if y > 0:
				y -= 1
				r += j
			else:
				x -= 1
				r += i
		elif x > 0:
			x -= 1
			r += i
		else:
			y -= 1
			r += j
	print(r)


(n, x, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
lst = [a[i] - b[i] for i in range(n)]
lst.sort(reverse=1)
ans = sum(b)
for j in range(x):
	if lst[j] > 0:
		ans += lst[j]
print(ans)


(n, x, y) = [int(c) for c in input().split()]
a = [int(c) for c in input().split()]
b = [int(c) for c in input().split()]
d = [i - j for (i, j) in zip(a, b)]
ans = sum(a)
(xcount, ycount) = (0, 0)
d.sort(key=lambda x: abs(x), reverse=True)
for i in range(len(d)):
	if d[i] >= 0:
		if xcount < x:
			xcount += 1
		else:
			ycount += 1
			ans -= d[i]
	elif ycount < y:
		ycount += 1
		ans -= d[i]
	else:
		xcount += 1
print(ans)


(n, x, y) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
loss = list()
for i in range(0, n):
	loss.append((abs(a[i] - b[i]), i))
loss.sort()
loss.reverse()
ans = 0
for j in range(0, n):
	i = loss[j][1]
	if a[i] > b[i]:
		if x > 0:
			x = x - 1
			ans += a[i]
		else:
			ans += b[i]
			y = y - 1
	elif y > 0:
		y = y - 1
		ans += b[i]
	else:
		ans += a[i]
		x = x - 1
print(ans)


(N, X, Y) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
l = []
for i in range(N):
	l.append(A[i] - B[i])
l.sort(reverse=True)
countA = 1
countB = N
Sum = sum(B)
while countA <= X and l[countA - 1] >= 0 or countB > Y:
	Sum += l[countA - 1]
	countA += 1
	countB -= 1
print(Sum)


(n, x, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
profit = []
i = 0
for (v1, v2) in zip(a, b):
	profit.append((abs(v1 - v2), i))
	i += 1
profit.sort(reverse=1)
res = 0
for p in profit:
	(profit, index) = (p[0], p[1])
	costA = a[index]
	costB = b[index]
	if x > 0 and costA >= costB or y == 0:
		res += costA
		x -= 1
	else:
		res += costB
		y -= 1
print(res)


from math import *
import sys

def input():
	return sys.stdin.readline().replace('\n', '').strip()
sys.setrecursionlimit(10 ** 9)
for _ in range(1):
	(n, x, y) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l1 = []
	for i in range(n):
		ans = abs(a[i] - b[i])
		l1.append((ans, a[i], b[i]))
	l1.sort()
	real_ans = 0
	for (a, b, c) in l1[::-1]:
		if b >= c and x > 0:
			real_ans += b
			x -= 1
		elif b <= c and y > 0:
			real_ans += c
			y -= 1
		elif x == 0 and y > 0:
			real_ans += c
			y -= 1
		elif y == 0 and x > 0:
			real_ans += b
			x -= 1
	print(real_ans)


(N, P, Q) = map(int, input().split())
E = list(map(int, input().split()))
T = list(map(int, input().split()))
arr = [(E[i] - T[i], i) for i in range(N)]
arr.sort(reverse=True)
orders = 0
cost = 0
for (i, j) in arr:
	if i < 0:
		if orders + Q >= N:
			cost += T[j]
			Q -= 1
			orders += 1
			continue
	if P:
		cost += E[j]
		orders += 1
		P -= 1
	else:
		cost += T[j]
		orders += 1
		Q -= 1
print(cost)


temp = input().split()
(n, x, y) = (int(temp[0]), int(temp[1]), int(temp[2]))
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ganancia = [a, b]

def max_delivery_man(a, b):
	if a >= b:
		return 0
	return 1
l = []
for i in range(n):
	l.append((abs(a[i] - b[i]), i, max_delivery_man(a[i], b[i])))
l.sort(key=lambda e: e[0], reverse=True)
suma = 0
for elem in l:
	if elem[2] == 0 and x > 0:
		suma = suma + ganancia[elem[2]][elem[1]]
		x = x - 1
	elif elem[2] == 1 and y > 0:
		suma = suma + ganancia[elem[2]][elem[1]]
		y = y - 1
	else:
		suma = suma + ganancia[1 - elem[2]][elem[1]]
print(suma)


(N, X, Y) = map(int, input().split())
t1 = list(map(int, input().split()))
t2 = list(map(int, input().split()))
diff = []
for i in range(len(t1)):
	diff.append(t1[i] - t2[i])
diff.sort(reverse=1)
profit = sum(t2)
count = 1
count2 = N
while count <= X and diff[count - 1] >= 0 or count2 > Y:
	profit += diff[count - 1]
	count += 1
	count2 -= 1
print(profit)


(order, max_andy, max_bob) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ab = []
for i in range(order):
	ab.append((abs(a[i] - b[i]), i))
ab.sort()
ab.reverse()
s = 0
for j in range(order):
	k = ab[j][1]
	if a[k] > b[k] and max_andy > 0:
		s = s + a[k]
		max_andy = max_andy - 1
	elif a[k] > b[k] and max_andy == 0:
		s = s + b[k]
	elif b[k] > a[k] and max_bob > 0:
		s = s + b[k]
		max_bob = max_bob - 1
	else:
		s = s + a[k]
print(s)


(n, x, y) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
diffs = [0] * n
k = 0
for (i, j) in zip(a, b):
	diffs[k] = (abs(i - j), k)
	k += 1
diffs.sort(key=lambda x: x[0], reverse=True)
s = 0
for l in diffs:
	i = l[1]
	if a[i] >= b[i]:
		if x > 0:
			s += a[i]
			x -= 1
		else:
			s += b[i]
			y -= 1
	elif y > 0:
		s += b[i]
		y -= 1
	else:
		s += a[i]
		x -= 1
print(s)


(N, x, y) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
abs_val = [[i, abs(a[i] - b[i])] for i in range(N)]
abs_val.sort(key=lambda x: x[1], reverse=True)
tot_tip = 0
for item in abs_val:
	atip = a[item[0]]
	btip = b[item[0]]
	if atip > btip:
		if x != 0:
			x -= 1
			tot_tip += atip
		else:
			y -= 1
			tot_tip += btip
	elif y != 0:
		y -= 1
		tot_tip += btip
	else:
		tot_tip += atip
		x -= 1
print(tot_tip)