AtCoder Beginner Contest 160 - Red and Green Apples

You are going to eat X red apples and Y green apples.

You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C.

Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively.

From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible.

Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.

-----Constraints-----
 - 1 \leq X \leq A \leq 10^5
 - 1 \leq Y \leq B \leq 10^5
 - 1 \leq C \leq 10^5
 - 1 \leq p_i \leq 10^9
 - 1 \leq q_i \leq 10^9
 - 1 \leq r_i \leq 10^9
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
X Y A B C
p_1 p_2 ... p_A
q_1 q_2 ... q_B
r_1 r_2 ... r_C

-----Output-----
Print the maximum possible sum of the deliciousness of the eaten apples.

-----Sample Input-----
1 2 2 2 1
2 4
5 1
3

-----Sample Output-----
12

The maximum possible sum of the deliciousness of the eaten apples can be achieved as follows:
 - Eat the 2-nd red apple.
 - Eat the 1-st green apple.
 - Paint the 1-st colorless apple green and eat it.

Difficulty: MEDIUM

Starter code:

Solutions:
(X, Y, A, B, C) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
hoge = p[:X] + q[:Y] + r
hoge.sort(reverse=True)
print(sum(hoge[:X + Y]))


(x, y, aa, bb, cc) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
ary = a[:x] + b[:y] + c
ary.sort(reverse=True)
print(sum(ary[:x + y]))


(X, Y, A, B, C) = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
R += sorted(P)[-X:]
R += sorted(Q)[-Y:]
a = -(X + Y)
print(sum(sorted(R)[a:]))


(X, Y, A, B, C) = list(map(int, input().split()))
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)
pqr = sorted(p[:X] + q[:Y] + r, reverse=True)
print(sum(pqr[:X + Y]))


(x, y, a, b, c) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
ABC = A[:x] + B[:y] + C
ABC.sort(reverse=True)
print(sum(ABC[:x + y]))


(X, Y, A, B, C) = map(int, input().split())
P = sorted(map(int, input().split()), reverse=True)[:X]
Q = sorted(map(int, input().split()), reverse=True)[:Y]
R = sorted(P + Q + list(map(int, input().split())), reverse=True)[:X + Y]
print(sum(R))


(X, Y, A, B, C) = map(int, input().split())
p = sorted(sorted([int(x) for x in input().split()])[-X:] + sorted([int(x) for x in input().split()])[-Y:] + [int(x) for x in input().split()])
print(sum(p[-X - Y:]))


(X, Y, A, B, C) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
P = p[0:X]
Q = q[0:Y]
N = P + Q + r
N.sort(reverse=True)
print(sum(N[0:X + Y]))


(x, y, a, b, c) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r += p[:x] + q[:y]
r.sort(reverse=True)
ans = 0
for i in range(x + y):
	ans += r[i]
print(ans)


def MI():
	return map(int, input().split())

def LI():
	return list(MI())
(x, y, a, b, c) = MI()
p = sorted(LI())[::-1][:x]
q = sorted(LI())[::-1][:y]
r = sorted(LI())[::-1]
u = sorted(p + q + r)[::-1][:x + y]
print(sum(u))


from collections import deque
(x, y, a, b, c) = map(int, input().split())
ls = []
la = list(map(int, input().split()))
lb = list(map(int, input().split()))
lc = list(map(int, input().split()))
la.sort(reverse=True)
lb.sort(reverse=True)
lc.sort(reverse=True)
for i in range(a):
	ls.append([la[i], 1])
for j in range(b):
	ls.append([lb[j], 2])
for l in range(c):
	ls.append([lc[l], 3])
ls.sort(key=lambda x: x[0], reverse=True)
ls = deque(ls)
(s, t, k) = (0, 0, 0)
cnt = 0
while True:
	now = ls.popleft()
	if now[1] == 1:
		if s < x:
			cnt += now[0]
			s += 1
	elif now[1] == 2:
		if t < y:
			cnt += now[0]
			t += 1
	else:
		cnt += now[0]
		k += 1
	if s + t + k == x + y:
		print(cnt)
		break


(X, Y, A, B, C) = map(int, input().split())
P = sorted([int(i) for i in input().split()], reverse=True)
Q = sorted([int(i) for i in input().split()], reverse=True)
R = sorted([int(i) for i in input().split()])
S = sorted(P[:X] + Q[:Y] + R, reverse=True)
print(sum(S[:X + Y]))


(x, y, a, b, c) = map(int, input().split())
p = sorted(list(map(int, input().split())))[-x:]
q = sorted(list(map(int, input().split())))[-y:]
r = sorted(list(map(int, input().split())))
s = sorted(p + q + r)[-x - y:]
print(sum(s))


(x, y, a, b, c) = map(int, input().split())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))
al.sort(reverse=True)
bl.sort(reverse=True)
z = al[:x] + bl[:y] + cl
z.sort(reverse=True)
print(sum(z[:x + y]))


(x, y, a, b, c) = map(int, input().split())
print(sum(sorted(sorted((int(x) for x in input().split()))[-x:] + sorted((int(x) for x in input().split()))[-y:] + [int(x) for x in input().split()])[-(x + y):]))


import numpy as np
(x, y, a, b, c) = [int(i) for i in input().split()]
p = np.array([int(i) for i in input().split()])
q = np.array([int(i) for i in input().split()])
r = np.array([int(i) for i in input().split()])
p.sort()
q.sort()
r.sort()
p = p[-x:]
q = q[-y:]
if x + y < r.size:
	r = r[-x - y:]
apple = np.hstack([p, q, r])
apple.sort()
sweet = apple[-x - y:].sum()
print(sweet)


(x, y, a, b, c) = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)
L = P[:x] + Q[:y] + R
L.sort(reverse=True)
print(sum(L[:x + y]))


(X, Y, A, B, C) = map(int, input().split())
p = sorted(list(map(int, input().split())))[-X:]
q = sorted(list(map(int, input().split())))[-Y:]
r = sorted(list(map(int, input().split())))
print(sum(sorted(p + q + r)[-X - Y:]))


(X, Y, A, B, C) = map(int, input().split())
(*p,) = map(int, input().split())
(*q,) = map(int, input().split())
(*r,) = map(int, input().split())
p.sort(key=lambda x: -x)
q.sort(key=lambda x: -x)
p = p[:X]
q = q[:Y]
pqr = p + q + r
pqr.sort(key=lambda x: -x)
print(sum(pqr[:X + Y]))


def main():
	import heapq
	import sys
	pin = sys.stdin.readline
	pout = sys.stdout.write
	perr = sys.stderr.write
	(X, Y, A, B, C) = list(map(int, pin().split()))
	p = list(map(int, pin().split()))
	q = list(map(int, pin().split()))
	r = list(map(int, pin().split()))
	p.sort(reverse=True)
	q.sort(reverse=True)
	r.sort(reverse=True)
	p = p[:X]
	q = q[:Y]
	Q = []
	for i in p:
		Q.append([i, 0])
	for j in q:
		Q.append([j, 1])
	heapq.heapify(Q)
	cntp = 0
	cntq = 0
	ans = 0
	for k in r:
		t = heapq.heappop(Q)
		if t[1] == 0 and t[0] < k and (cntp <= X):
			ans += k
			cntp += 1
		elif t[1] == 1 and t[0] < k and (cntq <= Y):
			ans += k
			cntq += 1
		else:
			ans += t[0]
			break
	while True:
		try:
			s = heapq.heappop(Q)
			ans += s[0]
		except:
			break
	print(ans)
	return
main()


(x, y, a, b, c) = map(int, input().split())
p = sorted(list(map(int, input().split())))[::-1]
q = sorted(list(map(int, input().split())))[::-1]
r = list(map(int, input().split()))
p1 = p[:x]
q1 = q[:y]
l = sum(sorted(p1 + q1 + r)[::-1][:x + y])
print(l)


(X, Y, A, B, C) = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
from collections import deque
p.sort()
p = p[len(p) - X:]
q.sort()
q = q[len(q) - Y:]
r.sort(reverse=True)
p = deque(p)
q = deque(q)
for i in r:
	if min(p[0], q[0]) > i:
		break
	if p[0] < q[0]:
		p.popleft()
		p.append(i)
	else:
		q.popleft()
		q.append(i)
print(sum(p) + sum(q))


(x, y, a, b, c) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
s = p[:x] + q[:y]
s.sort()
ans = sum(s)
for (si, ri) in zip(s, r):
	if si < ri:
		ans += ri - si
print(ans)


from sys import stdin
nii = lambda : map(int, stdin.readline().split())
lnii = lambda : list(map(int, stdin.readline().split()))
(x, y, a, b, c) = nii()
p = sorted(lnii(), reverse=True)
q = sorted(lnii(), reverse=True)
r = sorted(lnii(), reverse=True)
l = p[:x] + q[:y]
l.sort()
ans = 0
for i in range(x + y):
	if i < c:
		ans += max(l[i], r[i])
	else:
		ans += l[i]
print(ans)


(X, Y, A, B, C) = map(int, input().split())
(p, q, r) = [sorted(map(int, input().split()), reverse=True) for i in range(3)]
ans = 0
(pp, qq) = ([p[i] for i in range(X)], [q[i] for i in range(Y)])
r = r + pp + qq
r = sorted(r, reverse=True)
for i in range(X + Y):
	ans += r[i]
print(ans)


from collections import deque
(X, Y, A, B, C) = map(int, input().split())
Q_A = list(map(int, input().split()))
Q_B = list(map(int, input().split()))
Q_C = list(map(int, input().split()))
Q_A = sorted(Q_A, reverse=True)[:X]
Q_B = sorted(Q_B, reverse=True)[:Y]
Q_C = sorted(Q_C, reverse=True)
cand = Q_A + Q_B + Q_C
cand = sorted(cand, reverse=True)
print(sum(cand[:X + Y]))


def main():
	import sys

	def input():
		return sys.stdin.readline().rstrip()
	(x, y, a, b, c) = map(int, input().split())
	p = list(map(int, input().split()))
	q = list(map(int, input().split()))
	r = list(map(int, input().split()))
	p.sort(reverse=True)
	q.sort(reverse=True)
	r = p[:x] + q[:y] + r
	r.sort(reverse=True)
	print(sum(r[:x + y]))

def __starting_point():
	main()
__starting_point()


(x, y, a, b, c) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
q.sort()
nums = p[-x:] + q[-y:] + r
nums.sort()
print(sum(nums[-(x + y):]))


(X, Y, A, B, C) = [int(x) for x in input().split()]
p = sorted([int(x) for x in input().split()], reverse=True)[:X]
q = sorted([int(x) for x in input().split()], reverse=True)[:Y]
r = sorted([int(x) for x in input().split()], reverse=True)[:X + Y]
s = sorted(p + q + r, reverse=True)
ans = sum(s[:X + Y])
print(ans)


f = lambda : list(map(int, input().split()))
(X, Y, *e) = f()
P = f()
Q = f()
R = f()
P.sort()
Q.sort()
R.sort()
print(sum(sorted(P[-X:] + Q[-Y:] + R)[-X - Y:]))


def LI():
	return list(map(int, input().split()))
(X, Y, A, B, C) = LI()
red = LI()
green = LI()
mu = LI()
red.sort(reverse=True)
green.sort(reverse=True)
ans = red[:X] + green[:Y] + mu
ans.sort(reverse=True)
total = 0
for i in range(X + Y):
	total += ans[i]
print(total)


import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007

def main():
	(X, Y, A, B, C) = list(map(int, readline().split()))
	P = list(map(int, readline().split()))
	Q = list(map(int, readline().split()))
	R = list(map(int, readline().split()))
	P.sort(reverse=True)
	Q.sort(reverse=True)
	apple = P[:X] + Q[:Y] + R
	apple.sort(reverse=True)
	print(sum(apple[:X + Y]))
	return

def __starting_point():
	main()
__starting_point()


(x, y, a, b, c) = list(map(int, input().split()))
plst = list(map(int, input().split()))
qlst = list(map(int, input().split()))
rlst = list(map(int, input().split()))
plst.sort()
qlst.sort()
rlst.sort(reverse=True)
inf = 10 ** 20
plst = plst[-x:] + [inf]
qlst = qlst[-y:] + [inf]
r_pos = 0
p_pos = 0
q_pos = 0
while 1:
	if rlst[r_pos] <= plst[p_pos] and rlst[r_pos] <= qlst[q_pos]:
		break
	elif plst[p_pos] < qlst[q_pos]:
		plst[p_pos] = rlst[r_pos]
		p_pos += 1
		r_pos += 1
	else:
		qlst[q_pos] = rlst[r_pos]
		q_pos += 1
		r_pos += 1
	if r_pos == c:
		break
print(sum(plst) + sum(qlst) - inf * 2)


i = lambda : list(map(int, input().split()))
s = lambda k, l: sorted(k)[-l:]
(x, y, *a) = i()
print(sum(s(s(i(), x) + s(i(), y) + i(), x + y)))


import heapq
(X, Y, A, B, C) = map(int, input().split())
Plist = list(map(int, input().split()))
Qlist = list(map(int, input().split()))
Rlist = list(map(int, input().split()))
Plist.sort(reverse=True)
Qlist.sort(reverse=True)
Rlist.sort(reverse=True)
(i, j, k) = (0, 0, 0)
pmax = Plist[i]
qmax = Qlist[i]
rmax = Rlist[i]
Ans = 0
for _ in range(2 * 10 ** 5):
	Ans += max(pmax, qmax, rmax)
	if pmax == max(pmax, qmax, rmax):
		i += 1
		if i != X:
			pmax = Plist[i]
		else:
			pmax = -1
	elif qmax == max(pmax, qmax, rmax):
		j += 1
		if j != Y:
			qmax = Qlist[j]
		else:
			qmax = -1
	else:
		k += 1
		try:
			rmax = Rlist[k]
		except:
			rmax = -1
	if i + j + k == X + Y:
		break
print(Ans)


(x, y, a, b, c) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
q.sort()
r.sort()
w = p[a - x:a] + q[b - y:b] + r
w.sort()
print(sum(w[len(w) - (x + y):len(w)]))


(x, y, a, b, c) = map(int, input().split())
p = sorted(list(map(int, input().split())))[::-1][:x]
q = sorted(list(map(int, input().split())))[::-1][:y]
r = sorted(list(map(int, input().split())))[::-1]
r = r[:min(len(r), x + y)]
l = sum([p, q, r], [])
print(sum(sorted(l)[::-1][:x + y]))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, bisect
import sys
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
stdin = sys.stdin
ni = lambda : int(ns())
nf = lambda : float(ns())
na = lambda : list(map(int, stdin.readline().split()))
nb = lambda : list(map(float, stdin.readline().split()))
ns = lambda : stdin.readline().rstrip()
(X, Y, A, B, C) = na()
p = na()
q = na()
r = na()
p.append(inf)
q.append(inf)
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
s1 = sum(p[1:X + 1])
s2 = sum(q[1:Y + 1])
p_idx = X
q_idx = Y
ans = s1 + s2
for i in range(C):
	now_r = r[i]
	now_p = p[p_idx]
	now_q = q[q_idx]
	if now_r <= now_p and now_r <= now_q:
		break
	elif now_r > now_p and now_r > now_q:
		if now_p > now_q:
			ans = ans + now_r - now_q
			q_idx -= 1
		else:
			ans = ans + now_r - now_p
			p_idx -= 1
	elif now_r > now_p:
		ans = ans + now_r - now_p
		p_idx -= 1
	elif now_r > now_q:
		ans = ans + now_r - now_q
		q_idx -= 1
print(ans)


(X, Y, A, B, C) = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
P.sort()
Q.sort()
R.sort()
P_new = P[-X:]
Q_new = Q[-Y:]
agg = P_new + Q_new + R
agg.sort()
print(sum(agg[-X - Y:]))


import math
import sys
import collections
import bisect
readline = sys.stdin.readline

def main():
	(x, y, a, b, c) = list(map(int, input().split()))
	p = sorted(list(map(int, input().split())), reverse=True)[0:x]
	q = sorted(list(map(int, input().split())), reverse=True)[0:y]
	r = sorted(list(map(int, input().split())), reverse=True)
	pq = sorted(p + q)
	for i in range(min(c, x + y)):
		if pq[i] > r[i]:
			break
		pq[i] = r[i]
	print(sum(pq))

def __starting_point():
	main()
__starting_point()


(x, y, a, b, c) = map(int, input().split())
p = sorted(map(int, input().split()), reverse=True)[:x]
q = sorted(map(int, input().split()), reverse=True)[:y]
r = list(map(int, input().split()))
ls = sorted(p + q + r, reverse=True)[:x + y]
print(sum(ls))


import heapq
(x, y, a, b, c) = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
ans = []
for i in range(x):
	ans.append(p[i])
for j in range(y):
	ans.append(q[j])
ans.sort()
heapq.heapify(ans)
for j in range(c):
	min_a = heapq.heappop(ans)
	if min_a <= r[j]:
		heapq.heappush(ans, r[j])
	else:
		heapq.heappush(ans, min_a)
		break
print(sum(ans))


(X, Y, A, B, C, *PQR) = map(int, open(0).read().split())
P = sorted(PQR[:A], reverse=True)
Q = sorted(PQR[A:A + B], reverse=True)
R = sorted(PQR[A + B:], reverse=True)
print(sum(sorted(P[:X] + Q[:Y] + R, reverse=True)[:X + Y]))


I = lambda : sorted([int(a) for a in input().split()])[::-1]
(X, Y, *_) = map(int, input().split())
print(sum(sorted(I()[:X] + I()[:Y] + I())[::-1][:X + Y]))


(x, y, a, b, c) = map(int, input().split())
P = sorted(list(map(int, input().split())))[::-1]
Q = sorted(list(map(int, input().split())))[::-1]
R = list(map(int, input().split()))
L = sorted(P[:x] + Q[:y] + R)[::-1]
print(sum(L[:x + y]))


(X, Y, A, B, C) = map(int, input().split())
lp = list(map(int, input().split()))
lq = list(map(int, input().split()))
lr = list(map(int, input().split()))
lp.sort()
lq.sort()
lr.sort()
lnew = lp[A - X:] + lq[B - Y:] + lr
lnew.sort()
print(sum(lnew[C:]))


(X, Y, A, B, C) = list(map(int, input().split()))
P = sorted(map(int, input().split()), reverse=True)[:X]
Q = sorted(map(int, input().split()), reverse=True)[:Y]
R = sorted(map(int, input().split()), reverse=True)
PQ = sorted(P + Q)
ans = sum(PQ)
for (r, pq) in zip(R, PQ):
	if r > pq:
		ans += r - pq
print(ans)


((X, Y, *e), *l) = [list(map(int, input().split())) for _ in [0] * 4]
s = sorted
(P, Q, R) = map(s, l)
print(sum(s(P[-X:] + Q[-Y:] + R)[-X - Y:]))


(x, y, a, b, c) = map(int, input().split())
datp = sorted(list(map(int, input().split())), reverse=True)
datq = sorted(list(map(int, input().split())), reverse=True)
datr = list(map(int, input().split()))
dat = sorted(datp[:x] + datq[:y] + datr, reverse=True)
print(sum(dat[:x + y]))


(x, y, a, b, c) = map(int, input().split())
p = [int(x) for x in input().rstrip().split()]
q = [int(x) for x in input().rstrip().split()]
r = [int(x) for x in input().rstrip().split()]
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p = p[:x]
q = q[:y]
pq = p + q
pqr = pq + r
pqr.sort(reverse=True)
print(sum(pqr[:x + y]))


(x, y, a, b, c) = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p = p[:x]
q = q[:y]
eat = p + q + r
eat.sort(reverse=True)
eat = eat[:x + y]
print(sum(eat))


(X, Y, A, B, C) = map(int, input().split())
ps = sorted(map(int, input().split()), reverse=True)[:X]
qs = sorted(map(int, input().split()), reverse=True)[:Y]
rs = list(map(int, input().split()))
print(sum(sorted(ps + qs + rs, reverse=True)[:X + Y]))


(X, Y, A, B, C) = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)
c = sorted(list(map(int, input().split())))
ans = sum(sorted(a[0:X] + b[0:Y] + c, reverse=True)[0:X + Y])
print(ans)


(X, Y, A, B, C) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
q.sort()
nums = p[-X:] + q[-Y:] + r
nums.sort()
print(sum(nums[-(X + Y):]))


mis = lambda : map(int, input().split())
lmis = lambda : list(mis())

def main():
	(X, Y, A, B, C) = mis()
	p = sorted(lmis(), reverse=True)[:X]
	q = sorted(lmis(), reverse=True)[:Y]
	r = lmis()
	print(sum(sorted(p + q + r, reverse=True)[:X + Y]))
main()


(X, Y, A, B, C) = map(int, input().split())
p = sorted(list(map(int, input().split())))[::-1]
q = sorted(list(map(int, input().split())))[::-1]
r = sorted(list(map(int, input().split())))[::-1]
i = X - 1
j = Y - 1
k = 0
p.append(float('INF'))
q.append(float('INF'))
r.append(-1)
while p[i] < r[k] or q[j] < r[k]:
	if p[i] < q[j]:
		i -= 1
		k += 1
	else:
		j -= 1
		k += 1
ans = 0
if i != -1:
	ans += sum(p[:i + 1])
if j != -1:
	ans += sum(q[:j + 1])
if k != 0:
	ans += sum(r[:k])
print(ans)


(x, y, a, b, c) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
q.sort()
pp = p[-x:]
qq = q[-y:]
eat = []
eat.extend(pp)
eat.extend(qq)
eat.extend(r)
eat.sort()
e = eat[-x - y:]
print(sum(e))


(x, y, a, b, c) = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)
pq = sorted(p[:x] + q[:y])
ans = sum(pq)
i = 0
while i < min(a + b, c):
	if r[i] <= pq[i]:
		break
	ans += r[i] - pq[i]
	i += 1
print(ans)


(x, y, a, b, c) = map(int, input().split())
p = sorted(list(map(int, input().split())))
q = sorted(list(map(int, input().split())))
r = sorted(list(map(int, input().split())))
ans = p[-x:] + q[-y:] + sorted(r)
print(str(sum(sorted(ans)[-x - y:])))


((x, y, a, b, c), *t) = [map(int, t.split()) for t in open(0)]
s = sorted
(p, q, r) = map(s, t)
print(sum(s(p[-x:] + q[-y:] + r)[-x - y:]))


import sys, math, collections, itertools, heapq
input = sys.stdin.readline

def f(n):
	return -1 * int(n)
(x, y, a, b, c) = list(map(int, input().split()))
p = sorted(list(map(int, input().split())), reverse=1)[:x]
q = sorted(list(map(int, input().split())), reverse=1)[:y]
r = list(map(f, input().split()))
p = collections.deque(p)
q = collections.deque(q)
heapq.heapify(r)
tmp = -1 * heapq.heappop(r)
while tmp > p[-1]:
	p.appendleft(tmp)
	tmp = p.pop()
	tmp = -1 * heapq.heappushpop(r, -1 * tmp)
while tmp > q[-1]:
	q.appendleft(tmp)
	tmp = q.pop()
	tmp = -1 * heapq.heappushpop(r, -1 * tmp)
print(sum(p) + sum(q))


[X, Y, A, B, C] = list(map(int, input().split()))
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
P.sort(reverse=True)
Q.sort(reverse=True)
S = P[0:X] + Q[0:Y] + R
S.sort(reverse=True)
print(sum(S[0:X + Y]))


(X, Y, A, B, C) = map(int, input().split())
Ap = list(map(int, input().split()))
Bq = list(map(int, input().split()))
Cr = list(map(int, input().split()))
Ap.sort()
Bq.sort()
print(sum(sorted(Ap[A - X:] + Bq[B - Y:] + Cr)[C:]))


from collections import deque
(X, Y, A, B, C) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
ALL = p + q + r
ALL.sort(reverse=True)
ALL = deque(ALL)
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p = deque(p)
q = deque(q)
r = deque(r)
ans = 0
p_cnt = 0
q_cnt = 0
r_cnt = 0
loopcnt = 0
while loopcnt < X + Y:
	apple = ALL.popleft()
	if p_cnt < X and apple == p[0]:
		ans += p.popleft()
		p_cnt += 1
		loopcnt += 1
	elif q_cnt < Y and apple == q[0]:
		ans += q.popleft()
		q_cnt += 1
		loopcnt += 1
	elif r_cnt < C and apple == r[0]:
		ans += r.popleft()
		r_cnt += 1
		loopcnt += 1
print(ans)


(x, y, a, b, c) = map(int, input().split())
(*p,) = sorted(map(int, input().split()))
(*q,) = sorted(map(int, input().split()))
(*r,) = map(int, input().split())
p = p[-x:]
q = q[-y:]
r = sorted(p + q + r)
print(sum(r[-x - y:]))
assert sum(r[-x - y:]) < 2 ** 63


(x, y, a, b, c) = map(int, input().split())
p = sorted(map(int, input().split()))
q = sorted(map(int, input().split()))
r = sorted(map(int, input().split()))
ans = p[-x:] + q[-y:] + r
ans.sort()
n = len(ans)
cnt = 0
for i in range(x + y):
	cnt += ans[n - 1 - i]
print(cnt)


(x, y, a, b, c) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
s = []
for i in range(a):
	s.append([p[i], 1])
for i in range(b):
	s.append([q[i], 2])
for i in range(c):
	s.append([r[i], 0])
s.sort(reverse=True)
o = 0
(X, Y, Z) = (0, 0, 0)
for i in range(a + b + c):
	if s[i][1] == 1 and X < x:
		X += 1
		Z += 1
		o += s[i][0]
	elif s[i][1] == 2 and Y < y:
		Y += 1
		Z += 1
		o += s[i][0]
	elif s[i][1] == 0:
		Z += 1
		o += s[i][0]
	if Z == x + y:
		break
print(o)


import sys
input = sys.stdin.readline

def main():
	(X, Y, A, B, C) = map(int, input().split())
	P = sorted(list(map(int, input().split())))
	Q = sorted(list(map(int, input().split())))
	R = sorted(list(map(int, input().split())))
	l = sorted(P[-X:] + Q[-Y:])
	ans = 0
	for i in range(len(l)):
		if len(R) > 0 and R[-1] > l[i]:
			ans += R.pop(-1)
		else:
			ans += l[i]
	print(ans)

def __starting_point():
	main()
__starting_point()


(x, y, a, b, c) = map(int, input().split())
p_l = sorted(list(map(int, input().split())), reverse=True)[:x]
q_l = sorted(list(map(int, input().split())), reverse=True)[:y]
r_l = list(map(int, input().split()))
p_l = sorted(p_l + q_l + r_l, reverse=True)
print(sum(p_l[:x + y]))


((x, y, *_), *t) = [map(int, t.split()) for t in open(0)]
s = sorted
(p, q, r) = map(s, t)
print(sum(s(p[-x:] + q[-y:] + r)[-x - y:]))


(x, y, a, b, c) = map(int, input().split())
p_array = list(map(int, input().split()))
q_array = list(map(int, input().split()))
r_array = list(map(int, input().split()))
p_array_sort = sorted(p_array, reverse=True)
q_array_sort = sorted(q_array, reverse=True)
r_array_sort = sorted(r_array, reverse=True)
p_i = x - 1
q_i = y - 1
for r in r_array_sort:
	p = p_array_sort[p_i]
	q = q_array_sort[q_i]
	if r <= p and r <= q:
		break
	elif q <= p:
		q_array_sort[q_i] = r
		q_i = max(q_i - 1, 0)
	else:
		p_array_sort[p_i] = r
		p_i = max(p_i - 1, 0)
ans = sum(p_array_sort[:x]) + sum(q_array_sort[:y])
print(ans)


import heapq
(x, y, a, b, c) = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = list(map(lambda x: -int(x), input().split()))
heapq.heapify(r)
for i in range(x):
	heapq.heappush(r, -p[i])
for i in range(y):
	heapq.heappush(r, -q[i])
ans = 0
for i in range(x + y):
	ans -= heapq.heappop(r)
print(ans)


(x, y, a, b, c) = [int(x) for x in input().split()]
p = sorted([int(x) for x in input().split()], reverse=True)[:x]
q = sorted([int(x) for x in input().split()], reverse=True)[:y]
r = sorted([int(x) for x in input().split()])
print(sum(sorted(p + q + r, reverse=True)[:x + y]))


import sys
from io import StringIO
import unittest
import heapq

def yn(b):
	print('Yes' if b == 1 else 'No')
	return

def resolve():
	readline = sys.stdin.readline
	(X, Y, a, b, c) = list(map(int, readline().rstrip().split()))
	R = list([int(x) * -1 for x in readline().rstrip().split()])
	G = list([int(x) * -1 for x in readline().rstrip().split()])
	C = list([int(x) * -1 for x in readline().rstrip().split()])
	heapq.heapify(R)
	heapq.heapify(G)
	heapq.heapify(C)
	ans = []
	heapq.heapify(ans)
	for _ in range(X):
		a = heapq.heappop(R)
		heapq.heappush(ans, a)
	for _ in range(Y):
		a = heapq.heappop(G)
		heapq.heappush(ans, a)
	for _ in range(min(X + Y, c)):
		a = heapq.heappop(C)
		heapq.heappush(ans, a)
	a = 0
	for _ in range(X + Y):
		a += heapq.heappop(ans) * -1
	print(a)
	return
if 'doTest' not in globals():
	resolve()
	return


import heapq
(x, y, a, b, c) = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
ans = 0
red_cnt = 0
green_cnt = 0
cnt = 0
heap = []
for i in range(len(p)):
	heapq.heappush(heap, (-p[i], 0))
for i in range(len(q)):
	heapq.heappush(heap, (-q[i], 1))
for i in range(len(r)):
	heapq.heappush(heap, (-r[i], 2))
while len(heap):
	(_x, _y) = heapq.heappop(heap)
	if _y == 0 and red_cnt < x:
		red_cnt += 1
		ans += _x
		cnt += 1
	elif _y == 1 and green_cnt < y:
		green_cnt += 1
		ans += _x
		cnt += 1
	elif _y == 2:
		cnt += 1
		ans += _x
	if cnt == x + y:
		print(-ans)
		return


(x, y, nr, ng, nm) = map(int, input().split())
r = list(map(int, input().split()))
g = list(map(int, input().split()))
m = list(map(int, input().split()))
r.sort(reverse=True)
g.sort(reverse=True)
a = r[:x] + g[:y] + m
a.sort(reverse=True)
print(sum(a[:x + y]))


(X, Y, A, B, C) = map(int, input().split())
plist = list(map(int, input().split()))
qlist = list(map(int, input().split()))
rlist = list(map(int, input().split()))
plist.sort()
qlist.sort()
rlist.sort()
plist = plist[::-1][:X]
qlist = qlist[::-1][:Y]
rlist = rlist[::-1]
pqrlist = plist + qlist + rlist
pqrlist.sort()
pqrlist = pqrlist[::-1]
print(sum(pqrlist[:X + Y]))


(x, y, a, b, c) = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]
r = [int(i) for i in input().split()]
p.sort()
q.sort()
r.sort()
p = p[-x:]
q = q[-y:]
ans = p + q + r
ans.sort()
ans = ans[-x - y:]
print(sum(ans))


(X, Y, A, B, C) = list(map(int, input().split()))
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)
p_list = p[:X]
q_list = q[:Y]
mylist = sorted(p_list + q_list + r, reverse=True)
ans = 0
for i in range(X + Y):
	ans += mylist[i]
print(ans)


(x, y, a, b, c) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
q.sort()
z = p[-x:]
z.extend(q[-y:])
z.extend(r)
z.sort()
print(sum(z[-x - y:]))


(x, y, a, b, c) = list(map(int, input().split()))
p = [0] + sorted(list(map(int, input().split())))[a - x:]
q = [0] + sorted(list(map(int, input().split())))[b - y:]
r = [0] + sorted(list(map(int, input().split())))
pi = -1
qi = -1
ri = -1
gs = 0
rs = 0
ws = 0
s = 0
while gs + rs + ws != x + y:
	if r[ri] >= q[qi] >= p[pi]:
		s += r[ri]
		ws += 1
		ri -= 1
	elif r[ri] >= p[pi] >= q[qi]:
		s += r[ri]
		ws += 1
		ri -= 1
	elif q[qi] >= r[ri] >= p[pi]:
		s += q[qi]
		gs += 1
		qi -= 1
	elif q[qi] >= p[pi] >= r[ri]:
		s += q[qi]
		gs += 1
		qi -= 1
	elif p[pi] >= r[ri] >= q[qi]:
		s += p[pi]
		rs += 1
		pi -= 1
	elif p[pi] >= q[qi] >= r[ri]:
		s += p[pi]
		rs += 1
		pi -= 1
print(s)


(x, y, a, b, c) = list(map(int, input().split()))
pA = list(map(lambda x: (int(x), 'a'), input().split()))
pB = list(map(lambda x: (int(x), 'b'), input().split()))
pC = list(map(lambda x: (int(x), 'c'), input().split()))
apples = sorted(pA + pB + pC)
cntA = 0
cntB = 0
cntC = 0
cnt = 0
while cntA + cntB + cntC < x + y:
	(val, col) = apples.pop()
	if col == 'a' and cntA < x:
		cntA += 1
		cnt += val
	elif col == 'b' and cntB < y:
		cntB += 1
		cnt += val
	elif col == 'c':
		cntC += 1
		cnt += val
print(cnt)


(X, Y, A, B, C) = map(int, input().split())
R = sorted(list(map(int, input().split())), reverse=True)
G = sorted(list(map(int, input().split())), reverse=True)
RG = sorted(list(map(int, input().split())), reverse=True)
d = R[:X] + G[:Y] + RG
d.sort(reverse=True)
print(sum(d[:X + Y]))


(x, y, a, b, c) = map(int, input().split())
r = sorted(list(map(int, input().split())), reverse=True)
g = sorted(list(map(int, input().split())), reverse=True)
w = list(map(int, input().split()))
p = sorted(r[:x] + g[:y] + w, reverse=True)
print(sum(p[:x + y]))


(X, Y, a, b, c) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
if X < a:
	A = A[a - X:]
if Y < b:
	B = B[b - Y:]
ans = 0
for i in range(X + Y):
	if len(A) == 0:
		A.append(0)
	if len(B) == 0:
		B.append(0)
	if len(C) == 0:
		C.append(0)
	if max(A[-1], B[-1], C[-1]) == A[-1]:
		ans += A[-1]
		A.pop()
	elif max(A[-1], B[-1], C[-1]) == B[-1]:
		ans += B[-1]
		B.pop()
	else:
		ans += C[-1]
		C.pop()
print(ans)


(X, Y, A, B, C) = map(int, input().split())
P = sorted([int(x) for x in input().split()])
Q = sorted([int(x) for x in input().split()])
R = sorted([int(x) for x in input().split()])
final = sorted(P[A - X:] + Q[B - Y:] + R, reverse=True)
print(sum(final[:X + Y]))


((x, y, a, b, c), p, q, r) = [map(int, o.split()) for o in open(0)]
print(sum(sorted(sorted(p)[-x:] + sorted(q)[-y:] + list(r))[-x - y:]))


(x, y, a, b, c) = map(int, input().split())
p = sorted([int(x) for x in input().split()])[::-1][:x]
q = sorted([int(x) for x in input().split()])[::-1][:y]
r = [int(x) for x in input().split()]
row = sorted(p + q + r)[::-1]
print(sum(row[:x + y]))


(x, y, a, b, c) = map(int, input().split())
R = sorted(map(int, input().split()), reverse=True)
G = sorted(map(int, input().split()), reverse=True)
N = sorted(map(int, input().split()), reverse=True)
L = sorted(R[:x] + G[:y] + N[:x + y], reverse=True)
print(sum(L[:x + y]))


import sys
rl = lambda : list(map(int, input().split()))
(x, y, a, b, c) = rl()
p = rl()
q = rl()
r = rl()
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
res = sum(sorted(p[:x] + q[:y] + r, reverse=True)[:x + y])
print(res)


def r():
	return map(int, input().split())
(x, y, a, b, c) = r()
print(sum(sorted(sorted(r())[-x:] + sorted(r())[-y:] + list(r()))[-x - y:]))


(x, y, a, b, c) = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
q.sort()
p0 = p[-x:]
q0 = q[-y:]
all1 = p0 + q0 + r
all1.sort()
print(sum(all1[-(x + y):]))


(X, Y, A, B, C) = map(int, input().split())
(*P,) = sorted(map(int, input().split()))
(*Q,) = sorted(map(int, input().split()))
(*R,) = map(int, input().split())
P = P[-X:]
Q = Q[-Y:]
R = sorted(P + Q + R)
ans = sum(R[-(X + Y):])
print(ans)


(x, y, a, b, c) = map(int, input().split())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]
r = [int(i) for i in input().split()]
p = sorted(p)
q = sorted(q)
tmp = sorted(p[-x:] + q[-y:] + r)
ans = sum(tmp[-(x + y):])
print(ans)


(X, Y, A, B, C) = list(map(int, input().split()))
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)
red = p[:X]
green = q[:Y]
red_no_eat = 0
green_no_eat = 0
for no in r:
	red_worst = red[-red_no_eat - 1] if red_no_eat < X else 10 ** 10
	green_worst = green[-green_no_eat - 1] if green_no_eat < Y else 10 ** 10
	if no > red_worst or no > green_worst:
		if red_worst < green_worst:
			red_no_eat += 1
		else:
			green_no_eat += 1
print(sum(p[:X - red_no_eat]) + sum(q[:Y - green_no_eat]) + sum(r[:red_no_eat + green_no_eat]))


(x, y, a, b, c) = [int(i) for i in input().split()]
red_list = [int(i) for i in input().split()]
green_list = [int(i) for i in input().split()]
non_col_list = [int(i) for i in input().split()]
red_list.sort()
green_list.sort()
non_col_list.sort()
eat_red = []
eat_green = []
for i in range(x):
	eat_red.append(red_list.pop())
for i in range(y):
	eat_green.append(green_list.pop())
ans_list = eat_green + eat_red + non_col_list
ans_list.sort()
ans = 0
for i in range(x + y):
	ans += ans_list.pop()
print(ans)


(x, y, a, b, c) = map(int, input().split())
taste = [sorted(list(map(int, input().split())), reverse=True) for i in range(3)]
red = taste[0][:x]
green = taste[1][:y]
noclo = taste[2]
print(sum(sorted(red + green + noclo)[-(x + y):]))


(x, y, a, b, c) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p = sorted(p, reverse=True)
q = sorted(q, reverse=True)
r = sorted(r)
box = []
ans = 0
for i in range(x):
	box.append(p[i])
for j in range(y):
	box.append(q[j])
box = box + r
box = sorted(box, reverse=True)
for k in range(x + y):
	ans += box[k]
print(ans)


(x, y, a, b, c) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=1)
q.sort(reverse=1)
r.sort(reverse=1)
m = p[:x] + q[:y] + r
m.sort(reverse=1)
print(sum(m[:x + y]))


(X, Y, A, B, C) = map(int, input().split())
p = sorted([int(p) for p in input().split()])[-X:]
q = sorted([int(q) for q in input().split()])[-Y:]
r = [int(r) for r in input().split()]
lst = sorted(p + q + r)
print(sum(lst[-(X + Y):]))


import sys
sys.setrecursionlimit(10 ** 9)

def int1(x):
	return int(x) - 1

def II():
	return int(input())

def MI():
	return list(map(int, input().split()))

def MI1():
	return list(map(int1, input().split()))

def LI():
	return list(map(int, input().split()))

def LI1():
	return list(map(int1, input().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def MS():
	return input().split()

def LS():
	return list(input())

def LLS(rows_number):
	return [LS() for _ in range(rows_number)]

def printlist(lst, k=' '):
	print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
	(X, Y, A, B, C) = MI()
	L = []
	for r in LI():
		L.append((r, 'R'))
	for g in LI():
		L.append((g, 'G'))
	for t in LI():
		L.append((t, 'T'))
	L = sorted(L, reverse=True)
	ans = 0
	left = X + Y
	for (n, c) in L:
		if c == 'R':
			if X > 0:
				ans += n
				X -= 1
			else:
				continue
		elif c == 'G':
			if Y > 0:
				ans += n
				Y -= 1
			else:
				continue
		else:
			ans += n
		left -= 1
		if left == 0:
			print(ans)
			return

def __starting_point():
	solve()
__starting_point()


import sys
input = sys.stdin.readline
(X, Y, A, B, C) = map(int, input().split())
P = sorted(map(int, input().split()), reverse=True)
Q = sorted(map(int, input().split()), reverse=True)
R = list(map(int, input().split()))
C = P[:X] + Q[:Y] + R
C.sort(reverse=True)
print(sum(C[:X + Y]))


(X, Y, A, B, C) = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
P.sort()
Q.sort()
cand = P[-X:] + Q[-Y:] + R
cand.sort()
print(sum(cand[-(X + Y):]))


(x, y, a, b, c) = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
P.sort()
Q.sort()
R = R + P[a - x:] + Q[b - y:]
R.sort()
print(sum(R[-(x + y):]))


(f, g) = (lambda : map(int, input().split()), sorted)
(x, y, *_) = f()
print(sum(g(g(f())[-x:] + g(f())[-y:] + g(f()))[-x - y:]))


(x, y, a, b, c) = map(int, input().split())
print(sum(sorted(sorted(list(map(int, input().split())), reverse=True)[:x] + sorted(list(map(int, input().split())), reverse=True)[:y] + list(map(int, input().split())), reverse=True)[:x + y]))


import heapq
(x, y, a, b, c) = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)
x_tmp = P[:x]
y_tmp = Q[:y]
tmp_li = x_tmp + y_tmp
heapq.heapify(tmp_li)
for i in range(c):
	if R[i] > tmp_li[0]:
		heapq.heapreplace(tmp_li, R[i])
print(sum(tmp_li))


(X, Y, A, B, C) = map(int, input().split())
l = list(map(int, input().split()))
m = list(map(int, input().split()))
n = list(map(int, input().split()))
l = sorted(l, reverse=True)[:X]
m = sorted(m, reverse=True)[:Y]
print(sum(sorted(l + m + n, reverse=True)[:X + Y]))


(X, Y, a, b, c) = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
s = sorted(p)[::-1][:X] + sorted(q)[::-1][:Y] + r
s = sorted(s)[::-1]
ans = sum(s[:X + Y])
print(ans)


import sys

def input():
	return sys.stdin.readline().rstrip()

def main():
	(x, y, a, b, c) = map(int, input().split())
	p = list(map(int, input().split()))
	q = list(map(int, input().split()))
	r = list(map(int, input().split()))
	p.sort(reverse=True)
	q.sort(reverse=True)
	r.sort(reverse=True)
	p = [10 ** 10] + p[:x]
	q = [10 ** 10] + q[:y]
	r += [0] * (a + b)
	ans = sum(p) + sum(q) - 2 * 10 ** 10
	(pcnt, qcnt) = (0, 0)
	for i in range(x + y):
		if p[-1 - pcnt] >= r[i] and q[-1 - qcnt] >= r[i]:
			break
		elif p[-1 - pcnt] > q[-1 - qcnt]:
			ans += -q[-1 - qcnt] + r[i]
			qcnt += 1
		else:
			ans += -p[-1 - pcnt] + r[i]
			pcnt += 1
	print(ans)

def __starting_point():
	main()
__starting_point()


(x, y, a, b, c) = map(int, input().split())
r = sorted(list(map(int, input().split())))[a - x:]
g = sorted(list(map(int, input().split())))[b - y:]
m = list(map(int, input().split()))
ans = sorted(r + g + m)
print(sum(ans[len(ans) - x - y:]))


(x, y, a, b, c) = list(map(int, input().split()))
p = [0] + list(map(int, input().split()))
q = [0] + list(map(int, input().split()))
r = [0] + list(map(int, input().split()))
p.sort()
q.sort()
r.sort()
ans = 0
num = x + y
for _ in range(num):
	if x > 0 and y > 0:
		(i, j, k) = (p[-1], q[-1], r[-1])
		if i >= j and i >= k:
			ans += i
			p.pop()
			x -= 1
		elif j >= i and j >= k:
			ans += j
			q.pop()
			y -= 1
		else:
			ans += k
			r.pop()
	elif x > 0:
		(i, j) = (p[-1], r[-1])
		x -= 1
		if i >= j:
			ans += i
			p.pop()
		else:
			ans += j
			r.pop()
	elif y > 0:
		y -= 1
		(i, j) = (q[-1], r[-1])
		if i >= j:
			ans += i
			q.pop()
		else:
			ans += j
			r.pop()
print(ans)


(X, Y, A, B, C) = list(map(int, input().split()))
P = sorted(list(map(int, input().split())), reverse=True)
Q = sorted(list(map(int, input().split())), reverse=True)
R = sorted(list(map(int, input().split())), reverse=True)
pq = sorted(P[:X] + Q[:Y])
cnt = 0
for i in range(min(C, X + Y)):
	if R[i] <= pq[i]:
		break
	cnt += 1
ans = sum(pq[cnt:]) + sum(R[:cnt])
print(ans)


(x, y, a, b, c) = map(int, input().split())
p1 = list(map(int, input().split()))
p2 = list(map(int, input().split()))
p3 = list(map(int, input().split()))
p1.sort(reverse=True)
p2.sort(reverse=True)
ans = p1[:x] + p2[:y] + p3
ans.sort(reverse=True)
print(sum(ans[:x + y]))


(X, Y, A, B, C) = map(int, input().split())
P = sorted(map(int, input().split()), reverse=True)[:X]
Q = sorted(map(int, input().split()), reverse=True)[:Y]
R = sorted(map(int, input().split()), reverse=True)[:X + Y]
(i, j) = (X - 1, Y - 1)
for r in R:
	if i == -1 and j == -1:
		break
	elif j == -1:
		if r > P[i]:
			P[i] = r
			i -= 1
		else:
			break
	elif i == -1:
		if r > Q[j]:
			Q[j] = r
			j -= 1
		else:
			break
	elif P[i] > Q[j]:
		if r > Q[j]:
			Q[j] = r
			j -= 1
		else:
			break
	elif r > P[i]:
		P[i] = r
		i -= 1
	else:
		break
print(sum(P) + sum(Q))


(x, y, a, b, c) = map(int, input().split())
red = list(map(int, input().split()))
green = list(map(int, input().split()))
colorless = list(map(int, input().split()))
temp = []
red.sort(reverse=True)
green.sort(reverse=True)
colorless.sort(reverse=True)
for i in range(min(x, a)):
	temp.append(red[i])
for i in range(min(y, b)):
	temp.append(green[i])
for i in range(c):
	temp.append(colorless[i])
temp.sort(reverse=True)
ans = 0
for i in range(x + y):
	ans += temp[i]
print(ans)


(x, y, a, b, c) = map(int, input().split())
rs = [int(i) for i in input().split()]
gs = [int(i) for i in input().split()]
ws = [int(i) for i in input().split()]
rs.sort(reverse=True)
gs.sort(reverse=True)
ws.sort(reverse=True)
weight = 0
rs = rs[:x]
rs = [0] + rs
gs = gs[:y]
gs = [0] + gs
ws = [0] + ws
r = 0
g = 0
w = 0
while r + g + w < x + y:
	if r < x:
		w1 = weight + rs[r + 1]
	else:
		w1 = 0
	if g < y:
		w2 = weight + gs[g + 1]
	else:
		w2 = 0
	if w < c:
		w3 = weight + ws[w + 1]
	else:
		w3 = 0
	weight = max(w1, w2, w3)
	if weight == w1:
		r += 1
	elif weight == w2:
		g += 1
	elif weight == w3:
		w += 1
print(weight)


(X, Y, A, B, C) = map(int, input().split())
p_l = sorted(map(int, input().split()), reverse=True)
q_l = sorted(map(int, input().split()), reverse=True)
r_l = sorted(map(int, input().split()), reverse=True)
p = X
q = Y
r = 0
for i in range(min(X + Y, C)):
	if p == 0 and q == 0:
		break
	elif p == 0 and r_l[i] <= q_l[q - 1]:
		break
	elif q == 0 and r_l[i] <= p_l[p - 1]:
		break
	elif p == 0 and r_l[i] > q_l[q - 1]:
		(r, q) = (r + 1, q - 1)
	elif q == 0 and r_l[i] > p_l[p - 1]:
		(r, p) = (r + 1, p - 1)
	elif r_l[i] > q_l[q - 1] and p_l[p - 1] >= q_l[q - 1]:
		(r, q) = (r + 1, q - 1)
	elif r_l[i] > p_l[p - 1] and q_l[q - 1] >= p_l[p - 1]:
		(r, p) = (r + 1, p - 1)
	else:
		break
print(sum(p_l[:p]) + sum(q_l[:q]) + sum(r_l[:r]))


LMIIS = lambda : list(map(int, input().split()))
(X, Y, *e) = LMIIS()
P = LMIIS()
Q = LMIIS()
R = LMIIS()
P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)
print(sum(sorted(P[:X] + Q[:Y] + R, reverse=True)[:X + Y]))


(X, Y, A, B, C) = map(int, input().split())
R = list(map(int, input().split()))
G = list(map(int, input().split()))
T = list(map(int, input().split()))
R.sort(reverse=True)
G.sort(reverse=True)
R = R[:X]
G = G[:Y]
A = T + R + G
A.sort(reverse=True)
print(sum(A[:X + Y]))


(x, y, a, b, c) = map(int, input().split())
l = [list(map(int, input().split())) for i in range(3)]
k = sorted(l[0], reverse=True)[:x]
for i in sorted(l[1], reverse=True)[:y]:
	k.append(i)
for i in l[2]:
	k.append(i)
m = sorted(k, reverse=True)[:x + y]
print(sum(m))


(X, Y, A, B, C) = list(map(int, input().split()))
P = list([[int(s), 1] for s in input().split()])
Q = list([[int(s), 2] for s in input().split()])
R = list([[int(s), 0] for s in input().split()])
L = P + Q + R
L.sort(reverse=True, key=lambda x: x[0])
T = X + Y
(nr, ng, total) = (0, 0, 0)
ans = 0
for i in range(A + B + C):
	(a, l) = L[i]
	if l == 1 and nr < X:
		nr += 1
		ans += a
		total += 1
	if l == 2 and ng < Y:
		ng += 1
		ans += a
		total += 1
	if l == 0:
		ans += a
		total += 1
	if total == T:
		break
print(ans)


(x, y, a, b, c) = (int(i) for i in input().split())
p = sorted([int(i) for i in input().split()])
q = sorted([int(i) for i in input().split()])
r = sorted([int(i) for i in input().split()])
l = sorted(p[a - x:] + q[b - y:] + r)
n = len(l)
print(sum(l[n - x - y:]))


(x, y, a, b, c) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
p2 = p[:x]
q2 = q[:y]
l = p2 + q2 + r
l.sort(reverse=True)
ans = sum(l[:x + y])
print(ans)


(X, Y, A, B, C) = map(int, input().split())
r = sorted(list(map(int, input().split())), reverse=True)[:X]
g = sorted(list(map(int, input().split())), reverse=True)[:Y]
w = list(map(int, input().split()))
new = sorted(r + g + w, reverse=True)
print(sum(new[:X + Y]))


import heapq
(X, Y, A, B, C) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort()
s = p[:X] + q[:Y]
ans = sum(s)
heapq.heapify(s)
while r and s:
	if s[0] < r[-1]:
		ans += r[-1]
		r.pop()
		ans -= heapq.heappop(s)
	else:
		break
print(ans)


import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter, defaultdict, deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
mod = 10 ** 9 + 7

def inp():
	return int(input())

def inpm():
	return map(int, input().split())

def inpl():
	return list(map(int, input().split()))

def inpls():
	return list(input().split())

def inplm(n):
	return list((int(input()) for _ in range(n)))

def inplL(n):
	return [list(input()) for _ in range(n)]

def inplT(n):
	return [tuple(input()) for _ in range(n)]

def inpll(n):
	return [list(map(int, input().split())) for _ in range(n)]

def inplls(n):
	return sorted([list(map(int, input().split())) for _ in range(n)])
(x, y, a, b, c) = inpm()
p = list(reversed(sorted(inpl())))
q = list(reversed(sorted(inpl())))
r = list(reversed(sorted(inpl())))
pp = x - 1
qq = y - 1
rr = 0
tmp = []
tmp.extend(p[:pp + 1])
tmp.extend(q[:qq + 1])
tmp.extend(r)
tmp = list(reversed(sorted(tmp)))
ans = sum(tmp[:x + y])
print(ans)


(X, Y, A, B, C) = list(map(int, input().split()))
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
P.sort(reverse=True)
P = P[:X]
Q.sort(reverse=True)
Q = Q[:Y]
sp = sum(P)
sq = sum(Q)
ans = sp + sq
R.sort(reverse=True)
import heapq
heapq.heapify(P)
heapq.heapify(Q)
p = heapq.heappop(P)
q = heapq.heappop(Q)
r = R.pop(0)
while p < r or q < r:
	if r - p > r - q:
		heapq.heappush(P, r)
		ans += r - p
		p = heapq.heappop(P)
	else:
		heapq.heappush(Q, r)
		ans += r - q
		q = heapq.heappop(Q)
	if len(R) == 0:
		break
	r = R.pop(0)
print(ans)


(X, Y, A, B, C) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
q.sort()
k = p[-X:] + q[-Y:] + r
k.sort()
ans_list = k[-(X + Y):]
print(sum(ans_list))


(X, Y, A, B, C) = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
p = p[A - X:]
q = list(map(int, input().split()))
q.sort()
q = q[B - Y:]
r = list(map(int, input().split()))
apple = p + q + r
apple.sort()
print(sum(apple[len(apple) - X - Y:]))


(x_aka, y_mid, a, b, c) = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p_aka = sorted(p, reverse=True)
q_mid = sorted(q, reverse=True)
r_mu = sorted(r, reverse=True)
tmp = p_aka[:x_aka] + q_mid[:y_mid] + r_mu
sort_tmp = sorted(tmp, reverse=True)
print(sum(sort_tmp[:x_aka + y_mid]))


(X, Y, A, B, C) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
ans = sum(p[:X]) + sum(q[:Y])
x = X - 1
y = Y - 1
m = min(p[x], q[y])
n = 1
while len(r) > 0 and r[0] > m:
	if n == 1:
		if p[x] > q[y]:
			ans += r[0] - q[y]
			y -= 1
		else:
			ans += r[0] - p[x]
			x -= 1
	else:
		ans += r[0] - m
		if x < 0:
			y -= 1
		else:
			x -= 1
	r.pop(0)
	if y >= 0 and x >= 0:
		m = min(p[x], q[y])
	elif x >= 0 and y < 0:
		m = p[x]
		n = 0
	elif y >= 0 and x < 0:
		m = q[y]
		n = 0
	else:
		m = 10 ** 9 + 1
		n = 0
print(ans)


(x, y, a, b, c) = map(int, input().split())
P = map(int, input().split())
Q = map(int, input().split())
R = map(int, input().split())
e = sorted(P)[-x:]
e += sorted(Q)[-y:]
e += R
print(sum(sorted(e, reverse=True)[:x + y]))


(X, Y, A, B, C) = map(int, input().split())
Ps = list(map(int, input().split()))
Qs = list(map(int, input().split()))
Rs = list(map(int, input().split()))
Ps.sort(reverse=True)
Qs.sort(reverse=True)
Al = Ps[:X] + Qs[:Y] + Rs
Al.sort(reverse=True)
print(sum(Al[:X + Y]))


(x, y, a, b, c) = map(int, input().split())
red = [int(x) for x in input().split()]
green = [int(x) for x in input().split()]
red.sort()
green.sort()
candidates = [int(x) for x in input().split()] + red[-x:] + green[-y:]
candidates.sort()
print(sum(candidates[-x - y:]))


(x, y, a, b, c) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
ps = sorted(p, reverse=True)
qs = sorted(q, reverse=True)
pn = ps[:x]
qn = qs[:y]
nl = sorted(pn + qn + r, reverse=True)
print(sum(nl[:x + y]))


(X, Y, A, B, C) = map(int, input().split())
D = [sorted((int(x) for x in input().split())) for _ in range(3)]
print(sum(sorted(D[0][-X:] + D[1][-Y:] + D[2])[-(X + Y):]))


(x, y, a, b, c) = map(int, input().split())
R = list(map(int, input().split()))
G = list(map(int, input().split()))
W = list(map(int, input().split()))
R.sort(reverse=True)
G.sort(reverse=True)
Z = W + R[0:x] + G[0:y]
Z.sort(reverse=True)
print(sum(Z[0:x + y]))


(x, y, a, b, c) = list(map(int, input().split()))
p = sorted(list(map(int, input().split())))[-x:]
q = sorted(list(map(int, input().split())))[-y:]
r = sorted(list(map(int, input().split())))[::-1]
i = j = k = 0
oi = 0
while i < c:
	if x > j and y > k:
		if p[j] >= q[k] and q[k] < r[i]:
			q[k] = r[i]
			k += 1
			i += 1
		elif p[j] < q[k] and p[j] < r[i]:
			p[j] = r[i]
			j += 1
			i += 1
	elif x > j:
		if p[j] < r[i]:
			p[j] = r[i]
			j += 1
			i += 1
	elif y > k:
		if q[k] < r[i]:
			q[k] = r[i]
			k += 1
			i += 1
	if oi == i:
		break
	oi = i
print(sum(p) + sum(q))


import sys
sys.setrecursionlimit(10 ** 9)

def int1(x):
	return int(x) - 1

def II():
	return int(input())

def MI():
	return list(map(int, input().split()))

def MI1():
	return list(map(int1, input().split()))

def LI():
	return list(map(int, input().split()))

def LI1():
	return list(map(int1, input().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def MS():
	return input().split()

def LS():
	return list(input())

def LLS(rows_number):
	return [LS() for _ in range(rows_number)]

def printlist(lst, k=' '):
	print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
	(X, Y, A, B, C) = MI()
	R = sorted(LI(), reverse=True)[:X]
	G = sorted(LI(), reverse=True)[:Y]
	T = LI()
	L = sorted(R + G + T, reverse=True)[:X + Y]
	print(sum(L))

def __starting_point():
	solve()
__starting_point()


(X, Y, A, B, C) = map(int, input().split())
RO = list(map(int, input().split()))
GO = list(map(int, input().split()))
TO = list(map(int, input().split()))
RO.sort()
GO.sort()
R = RO[A - X:A]
G = GO[B - Y:B]
TO.extend(R)
TO.extend(G)
TO.sort(reverse=True)
T = TO[0:X + Y]
print(sum(T))


(x, y, a, b, c) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
q.sort()
L = p[a - x:a] + q[b - y:b] + r
L.sort()
L.reverse()
print(sum(L[0:x + y]))


(x, y, a, b, c) = map(int, input().split())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
A = A[::-1][:x]
B = B[::-1][:y]
C = C[::-1]
D = A + B + C
D.sort(reverse=True)
print(sum(D[:x + y]))


from heapq import heapify, heappop, heappush
(x, y, a, b, c) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
r = [-x for x in r]
p.sort()
q.sort()
r.sort()
p = p[-x:]
q = q[-y:]
heapify(p)
heapify(q)
heapify(r)
while r:
	pp = heappop(p)
	qq = heappop(q)
	rr = heappop(r)
	rr *= -1
	if pp >= rr and qq >= rr:
		heappush(p, pp)
		heappush(q, qq)
		break
	elif pp <= qq:
		heappush(q, qq)
		if pp < rr:
			heappush(p, rr)
	else:
		heappush(p, pp)
		if qq < rr:
			heappush(q, rr)
print(sum(p) + sum(q))


(x, y, a, b, c) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p = sorted(p, reverse=True)
q = sorted(q, reverse=True)
pq = sorted(p[:x] + q[:y])
r = sorted(r)
ans = 0
j = r.pop()
for i in pq:
	if i < j:
		ans += j
		j = 0
		if r:
			j = r.pop()
	else:
		ans += i
print(ans)


(X, Y, A, B, C) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p = sorted(p)[-X:]
q = sorted(q)[-Y:]
r = sorted(r)
a = p + q + r
a.sort(reverse=1)
ans = a[:X + Y]
print(sum(ans))


import heapq
from collections import deque
(must_red, must_green, a, b, c) = list(map(int, input().split()))
delicious_red_ls = list(map(int, input().split()))
delicious_green_ls = list(map(int, input().split()))
delicious_free_ls = list(map(int, input().split()))
delicious_red_ls.sort(reverse=True)
delicious_green_ls.sort(reverse=True)
first_red = delicious_red_ls[:must_red]
first_green = delicious_green_ls[:must_green]
first_set = first_green + first_red
first_set.sort()
delicious_free_ls.sort()
while delicious_free_ls:
	to_be_erased = heapq.heappop(first_set)
	erase = delicious_free_ls[-1]
	if to_be_erased < erase:
		new = delicious_free_ls.pop()
		heapq.heappush(first_set, new)
	else:
		heapq.heappush(first_set, to_be_erased)
		break
print(sum(first_set))


(x, y, a, b, c) = map(int, input().split())
p = sorted(list(map(int, input().split())))[::-1]
q = sorted(list(map(int, input().split())))[::-1]
r = sorted(list(map(int, input().split())))[::-1]
u = sorted(p[:x] + q[:y] + r)[::-1]
print(sum(u[:x + y]))


(X, Y, A, B, C) = map(int, input().split())
L = []
P = list(map(int, input().split()))
P.sort(reverse=True)
L += P[:X]
Q = list(map(int, input().split()))
Q.sort(reverse=True)
L += Q[:Y]
L += list(map(int, input().split()))
L.sort(reverse=True)
print(sum(L[:X + Y]))


(X, Y, A, B, C) = map(int, input().split())
p_list = list(map(int, input().split()))
q_list = list(map(int, input().split()))
r_list = list(map(int, input().split()))
p_list_max = sorted(p_list, reverse=True)
q_list_max = sorted(q_list, reverse=True)
r_list_max = sorted(r_list, reverse=True)
p_list_X = p_list_max[:X]
q_list_Y = q_list_max[:Y]
ans_list = []
ans_list.extend(p_list_X)
ans_list.extend(q_list_Y)
ans_list.extend(r_list_max)
ans_list_max = sorted(ans_list, reverse=True)
ans = 0
for i in range(X + Y):
	ans += ans_list_max[i]
print(ans)


(X, Y, A, B, C) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
p.reverse()
q.sort()
q.reverse()
new = p[0:X] + q[0:Y] + r
new.sort()
new.reverse()
print(sum(new[0:X + Y]))


L = lambda : map(int, input().split())
(x, y, a, b, c) = L()
(*p,) = L()
(*q,) = L()
(*r,) = L()
print(sum(sorted(sorted(p, reverse=1)[:x] + sorted(q, reverse=1)[:y] + r, reverse=1)[:x + y]))


(x, y, a, b, c) = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]
r = [int(i) for i in input().split()]
p = sorted(p)[::-1]
q = sorted(q)[::-1]
s = p[:x] + q[:y] + r[:]
s = sorted(s)[::-1]
ans = sum(s[:x + y])
print(ans)


(X, Y, A, B, C) = [int(n) for n in input().split(' ')]
p = [int(n) for n in input().split(' ')]
q = [int(n) for n in input().split(' ')]
r = [int(n) for n in input().split(' ')]
R = sorted(p)
G = sorted(q)
T = sorted(r)
W = 0
GetR = 0
GetG = 0
GetS = 0
while GetS < X + Y:
	a = -1
	b = -1
	c = -1
	if len(R) > 0 and GetR < X:
		a = R[-1]
	if len(G) > 0 and GetG < Y:
		b = G[-1]
	if len(T) > 0:
		c = T[-1]
	t = max([a, b, c])
	index = [a, b, c].index(t)
	W += t
	GetS += 1
	if index == 0:
		del R[-1]
		GetR += 1
	if index == 1:
		del G[-1]
		GetG += 1
	if index == 2:
		del T[-1]
print(W)


import numpy as np
(x, y, a, b, c) = map(int, input().split())
p = np.array(list(map(int, input().split())))
q = np.array(list(map(int, input().split())))
r = np.array(list(map(int, input().split())))
p.sort()
q.sort()
r.sort()
ans = p[-x:].sum() + q[-y:].sum()
p_cnt = 0
q_cnt = 0
r_cnt = 0
while not (-x + p_cnt == 0 and -y + q_cnt == 0) and -1 - r_cnt >= -c:
	if -x + p_cnt == 0:
		if r[-1 - r_cnt] > q[-y + q_cnt]:
			ans += r[-1 - r_cnt] - q[-y + q_cnt]
			q_cnt += 1
			r_cnt += 1
		else:
			break
	elif -y + q_cnt == 0:
		if r[-1 - r_cnt] > p[-x + p_cnt]:
			ans += r[-1 - r_cnt] - p[-x + p_cnt]
			p_cnt += 1
			r_cnt += 1
		else:
			break
	elif p[-x + p_cnt] <= q[-y + q_cnt] and r[-1 - r_cnt] > p[-x + p_cnt]:
		ans += r[-1 - r_cnt] - p[-x + p_cnt]
		p_cnt += 1
		r_cnt += 1
	elif p[-x + p_cnt] > q[-y + q_cnt] and r[-1 - r_cnt] > q[-y + q_cnt]:
		ans += r[-1 - r_cnt] - q[-y + q_cnt]
		q_cnt += 1
		r_cnt += 1
	else:
		break
print(ans)


from collections import deque
(X, Y, A, B, C) = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]
A = sorted(A, reverse=True)[:X]
B = sorted(B, reverse=True)[:Y]
AB = deque(sorted(A + B))
for c in sorted(C, reverse=True):
	if c >= AB[0]:
		AB.popleft()
		AB.append(c)
	else:
		break
print(sum(AB))


(X, Y, A, B, C) = map(int, input().split())
(p, q, r) = [list(map(int, input().split())) for _ in range(3)]
p = sorted(p, reverse=True)[:X]
q = sorted(q, reverse=True)[:Y]
l = p + q + r
l.sort(reverse=True)
print(sum(l[:X + Y]))


(x, y, a, b, c) = list(map(int, input().split()))
p = sorted(map(int, input().split()), reverse=True)
q = sorted(map(int, input().split()), reverse=True)
r = sorted(map(int, input().split()))
v = 0
c = sorted(p[0:x] + q[0:y])
for i in range(x + y):
	if len(r):
		if c[i] < r[-1]:
			c[i] = r.pop()
	else:
		break
print(sum(c))


(X, Y, A, B, C) = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
x = X - 1
y = Y - 1
p = sorted(p, reverse=True)
q = sorted(q, reverse=True)
r = sorted(r, reverse=True)
if p[x] >= q[y]:
	a = q[y]
	f = 1
else:
	a = p[x]
	f = 2
while len(r) >= 1 and a < r[0]:
	if f == 1:
		q[y] = r[0]
		y -= 1
		r.pop(0)
	elif f == 2:
		p[x] = r[0]
		x -= 1
		r.pop(0)
	else:
		break
	if y == -1 and x >= 0 or (x >= 0 and p[x] < q[y]):
		a = p[x]
		f = 2
	elif x == -1 and y >= 0 or (y >= 0 and p[x] >= q[y]):
		a = q[y]
		f = 1
	else:
		break
ans = 0
for i in p[:X]:
	ans += i
for i in q[:Y]:
	ans += i
print(ans)


def main():
	import heapq
	(x, y, a, b, c) = list(map(int, input().split()))
	p = sorted(list(map(int, input().split())), reverse=True)[0:x]
	q = sorted(list(map(int, input().split())), reverse=True)[0:y]
	r = sorted(list(map(int, input().split())), reverse=True)
	(P, Q) = ([], [])
	for i in range(x):
		heapq.heappush(P, p[i])
	for i in range(y):
		heapq.heappush(Q, q[i])
	for i in range(c):
		(p, q) = (heapq.heappop(P), heapq.heappop(Q))
		if p > q:
			heapq.heappush(P, p)
			if r[i] > q:
				heapq.heappush(Q, r[i])
			else:
				heapq.heappush(Q, q)
		else:
			heapq.heappush(Q, q)
			if r[i] > p:
				heapq.heappush(P, r[i])
			else:
				heapq.heappush(P, p)
	print(sum(P) + sum(Q))

def __starting_point():
	main()
__starting_point()


(a, b, red, green, cl) = map(int, input().split())
r = sorted(list(map(int, input().split())))[::-1]
g = sorted(list(map(int, input().split())))[::-1]
c = sorted(list(map(int, input().split())))[::-1]
s = sorted(r[:a] + g[:b] + c)[::-1]
print(sum(s[:a + b]))


from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque, Counter
from operator import mul
from functools import reduce
(x, y, a, b, c) = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p = sorted(p, reverse=True)[:x]
q = sorted(q, reverse=True)[:y]
r = sorted(r, reverse=True)
pq = sorted(p + q)
ans = sum(pq)
for i in range(len(r)):
	if pq[i] < r[i]:
		ans = ans + r[i] - pq[i]
	else:
		break
print(ans)


def main():
	(X, Y, A, B, C) = list(map(int, input().split()))
	p = list(map(int, input().split()))
	q = list(map(int, input().split()))
	r = list(map(int, input().split()))
	p.sort(reverse=True)
	q.sort(reverse=True)
	r.sort()
	p = p[:X]
	q = q[:Y]
	s = p + q
	s.sort()
	rtmp = r.pop()
	for i in range(len(s)):
		if s[i] < rtmp:
			s[i] = rtmp
			if len(r) == 0:
				break
			rtmp = r.pop()
		else:
			break
	ans = sum(s)
	print(ans)

def __starting_point():
	main()
__starting_point()


def main():
	(X, Y, A, B, C) = list(map(int, input().split()))
	(*P,) = list(map(int, input().split()))
	(*Q,) = list(map(int, input().split()))
	(*R,) = list(map(int, input().split()))
	P.sort(reverse=True)
	Q.sort(reverse=True)
	ans = sum(sorted(P[:X] + Q[:Y] + R, reverse=True)[:X + Y])
	print(ans)

def __starting_point():
	main()
__starting_point()


((x, y, a, b, c), p, q, r) = [[*list(map(int, i.split()))] for i in open(0)]
p = sorted(p)[-x:]
q = sorted(q)[-y:]
pq = sorted(p + q)
r.sort(reverse=True)
ans = sum(pq)
for i in range(min(c, x + y)):
	if r[i] > pq[i]:
		ans += r[i] - pq[i]
	else:
		break
print(ans)


f = lambda : map(int, input().split())
(x, y, a, b, c) = f()
l = sorted(sorted(f())[-x:] + sorted(f())[-y:] + list(f()))
print(sum(l[-x - y:]))


import heapq
import sys
(X, Y, A, B, C) = list(map(int, input().split()))
Av = list(map(int, input().split()))
Bv = list(map(int, input().split()))
Cv = list(map(int, input().split()))
heapq.heapify(Av)
heapq.heapify(Bv)
heapq.heapify(Cv)
for i in range(A - X):
	heapq.heappop(Av)
for i in range(B - Y):
	heapq.heappop(Bv)
if C > X + Y:
	for i in range(C - (X + Y)):
		heapq.heappop(Cv)
	NotTake = X + Y
else:
	NotTake = C
total = X + Y
C = NotTake
for _ in range(NotTake):
	Amin = heapq.heappop(Av)
	Bmin = heapq.heappop(Bv)
	Cmin = heapq.heappop(Cv)
	if X > 0 and Amin == min(Amin, Bmin, Cmin):
		heapq.heappush(Bv, Bmin)
		heapq.heappush(Cv, Cmin)
		X -= 1
	elif Y > 0 and Bmin == min(Bmin, Cmin):
		heapq.heappush(Av, Amin)
		heapq.heappush(Cv, Cmin)
		Y -= 1
	elif C > 0:
		heapq.heappush(Av, Amin)
		heapq.heappush(Bv, Bmin)
		C -= 1
	if X == 0 or Y == 0 or C == 0:
		break
NotTake = X + Y + C - total
if X == 0:
	Iv = Bv
	Jv = Cv
	I = Y
	J = C
elif Y == 0:
	Iv = Av
	Jv = Cv
	I = X
	J = C
else:
	print(sum(Av) + sum(Bv) + sum(Cv))
	return
for _ in range(NotTake):
	Imin = heapq.heappop(Iv)
	Jmin = heapq.heappop(Jv)
	if I > 0 and Imin == min(Imin, Jmin):
		heapq.heappush(Jv, Jmin)
		I -= 1
	elif J > 0:
		heapq.heappush(Iv, Imin)
		J -= 1
	if J == 0 or I == 0:
		break
print(sum(Av) + sum(Bv) + sum(Cv))


(X, Y, *_) = map(int, input().split())
print(sum(sorted(sorted(map(int, input().split()), reverse=True)[:X] + sorted(map(int, input().split()), reverse=True)[:Y] + list(map(int, input().split())), reverse=True)[:X + Y]))


(x, y, a, b, c) = map(int, input().split())
r = list(map(int, input().split()))
g = list(map(int, input().split()))
cl = list(map(int, input().split()))
r.sort(reverse=True)
g.sort(reverse=True)
ans = r[:x] + g[:y] + cl
print(sum(sorted(ans, reverse=True)[:x + y]))


(x, y, a, b, c) = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p2 = p[:x]
q2 = q[:y]
num = p2 + q2
num.sort()
ans = sum(num)
cnt = ans
for i in range(min(x + y, c)):
	cnt += r[i] - num[i]
	ans = max(ans, cnt)
print(ans)


import sys
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7

def resolve():
	(X, Y, A, B, C) = list(map(int, input().split()))
	P = sorted(list(map(int, input().split())), reverse=True)[:X]
	Q = sorted(list(map(int, input().split())), reverse=True)[:Y]
	R = sorted(list(map(int, input().split())), reverse=True)
	L = sorted(P + Q + R, reverse=True)
	res = sum(L[:X + Y])
	print(res)

def __starting_point():
	resolve()
__starting_point()


import math
import sys
import collections
import bisect
readline = sys.stdin.readline

def main():
	(x, y, a, b, c) = list(map(int, input().split()))
	print(sum(sorted(sorted(list(map(int, input().split())), reverse=True)[0:x] + sorted(list(map(int, input().split())), reverse=True)[0:y] + sorted(list(map(int, input().split())), reverse=True), reverse=True)[0:x + y]))

def __starting_point():
	main()
__starting_point()


(x, y, A, B, C) = map(int, input().split())
r = list(map(int, input().split()))
b = list(map(int, input().split()))
mu = list(map(int, input().split()))
mu += sorted(r)[-x:]
mu += sorted(b)[-y:]
print(sum(sorted(mu)[-(x + y):]))


s = sorted
((x, y, *_), p, q, r) = eval('map(int,input().split()),' * 4)
print(sum(s(s(p)[-x:] + s(q)[-y:] + s(r))[-x - y:]))


ni = lambda : int(input())
nm = lambda : map(int, input().split())
nl = lambda : list(map(int, input().split()))
(x, y, a, b, c) = nm()
ans = 0
p = sorted(nl())[::-1][:x]
q = sorted(nl())[::-1][:y]
r = sorted(nl())[::-1]
s = sorted(p + q + r)[::-1]
print(sum(s[:x + y]))


def main():
	(x, y, a, b, c) = map(int, input().split())
	ps = sorted(list(map(int, input().split())))
	qs = sorted(list(map(int, input().split())))
	rs = sorted(list(map(int, input().split())))
	points = sorted(ps[-x:] + qs[-y:])
	return sum(sorted(points + rs)[-x - y:])
print(main())