Problem:
 Score : 500 points    Problem Statement 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 1 2 2 2 1
2 4
5 1
3      Sample Output 1 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.        Sample Input 2 2 2 2 2 2
8 6
9 1
2 1      Sample Output 2 25       Sample Input 3 2 2 4 4 4
11 12 13 14
21 22 23 24
1 2 3 4      Sample Output 3 74

Solution (Python):
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)

X = p[:x] + q[:y] + r[:x+y]
X = sorted(X, reverse=True)

ans = sum(X[:x+y])
print(ans)

Solution (Python):
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)

apple = []
apple.extend(p[:x])
apple.extend(q[:y])
apple.extend(r)

apple.sort(reverse=True)
print(sum(apple[:x+y]))

Solution (Python):
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:]))

Solution (Python):
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]))

Solution (Python):
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,reverse=True)
answer=p[:X]+q[:Y]
sum=0
answer=sorted(answer)
i=0

while i<=min(X+Y-1,C-1) and answer[i]<r[i]:
    answer[i]=r[i]
    i+=1

for a in answer:
    sum+=a

print(sum)

Solution (Python):
from collections import deque
x,y,a,b,c = map(int,input().split())

p = deque(sorted(list(map(int,input().split()))))
q = deque(sorted(list(map(int,input().split()))))
r = deque(sorted(list(map(int,input().split()))))

ans = deque(maxlen=(x+y))

def insertion(z):
	global x,y
	if z == p:
		x -= 1
	else:
		y -= 1
	return ans.append(z.pop())

while x > 0 or y > 0:
	if x and y:
		if p[-1] > q[-1] :
			insertion(p)
		else:
			insertion(q)
	elif not x:
		insertion(q)
	else:
		insertion(p)

while r:
	if ans[-1] < r[-1]:
		ans.appendleft(r.pop())
	else:
		break

print(sum(ans))

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b,X,Y,Z = inpl()
x = sorted(inpl(), reverse = True)
y = sorted(inpl(), reverse = True)
z = sorted(inpl(), reverse = True)
x = x[:a]
y = y[:b]
apples = x + y + z
apples.sort(reverse = True)
print(sum(apples[:a+b]))

Solution (Python):
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[:X]
q = q[:Y]
r.extend(p)
r.extend(q)
r.sort(reverse=True)
ans = 0
for i in range(X+Y):
    ans += r[i]
print(ans)

Solution (Python):
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()))
tmp=sorted(p)
P=tmp[::-1]
tmp=sorted(q)
Q=tmp[::-1]
tmp=sorted(r)
R=tmp[::-1]
tmp=P[:X]+Q[:Y]+R
tmp=sorted(tmp)
tmp=tmp[::-1]
ans=sum(tmp[:X+Y])
print(ans)

Solution (Python):
X,Y,A,B,C = map(int, raw_input().split())
P = map(int, raw_input().split())
Q = map(int, raw_input().split())
R = map(int, raw_input().split())
 
Ps = sorted(P, reverse=True)
Qs = sorted(Q, reverse=True)
Rs = sorted(R, reverse=True)

Z = sorted(Ps[:X] + Qs[:Y] + Rs ,reverse=True)
print sum(Z[:X+Y])

Solution (Python):
x,y,a,b,c=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=list(map(int,input().split()))
print(sum(sorted(p+q+r,reverse=True)[:x+y]))

Solution (Python):
import heapq

def main():
    x,y,a,b,c = tuple([int(t)for t in input().split()])
    p = [int(t)for t in input().split()]
    q = [int(t)for t in input().split()]
    r = [int(t)for t in input().split()]

    p = sorted(p)[a-x:]
    q = sorted(q)[b-y:]

    r = sorted(r)

    while(len(r)>0):
        r_ = heapq.heappop(r)
        if r_-p[0]>=0 or r_-q[0]>=0:
            if r_-p[0]>r_-q[0]:
                heapq.heappop(p)
                heapq.heappush(p,r_)
            else:
                heapq.heappop(q)
                heapq.heappush(q,r_)

    print(sum(p)+sum(q))

if __name__ == "__main__":
    main()

Solution (Python):

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


resolve()

Solution (Python):
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)[:X]
q=sorted(q, reverse=True)[:Y]

gocha=sorted(p+q+r, reverse=True)

print(sum(gocha[:(X+Y)]))

Solution (Python):
import heapq

def main():
    x,y,a,b,c = tuple([int(t)for t in input().split()])
    p = [int(t)for t in input().split()]
    q = [int(t)for t in input().split()]
    r = [int(t)for t in input().split()]

    p = sorted(p)[a-x:]
    q = sorted(q)[b-y:]

    r = sorted(r)

    while(len(r)>0):
        r_ = heapq.heappop(r)
        if r_-p[0]>=0 or r_-q[0]>=0:
            if r_-p[0]>r_-q[0]:
                heapq.heappop(p)
                heapq.heappush(p,r_)
            else:
                heapq.heappop(q)
                heapq.heappush(q,r_)

    print(sum(p)+sum(q))

if __name__ == "__main__":
    main()

Solution (Python):
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)
lis=p[:x]+q[:y]+r
lis.sort(reverse=True)
ans=0
for i in range(x+y):
  ans+=lis[i]
print(ans)

Solution (Python):
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()
p.reverse()
q.reverse()
p=p[:X]
q=q[:Y]
 
a=p[:]
a.extend(q)
a.extend(r)
a.sort()
a.reverse()
sum=0
for i in range(X+Y):
  sum+=a[i]
print(sum)

Solution (Python):
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[:x]
q = q[:y]
ap = p + q + r
ap.sort(reverse=True)
print(sum(ap[:x+y]))

Solution (Python):
def main():
  X, Y, A, B, C  = map(int, input().split())
  aka_list = sorted([int(t) for t in input().split()],reverse=True)[:X]
  midori_list = sorted([int(t) for t in input().split()],reverse=True)[:Y]
  mu_list = sorted([int(t) for t in input().split()],reverse=True)
  
  sum_list = sorted(aka_list + midori_list + mu_list ,reverse=True)[:X+Y]
  print(sum(sum_list))

main()

Solution (Python):
(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:]))

Solution (Python):
x,y,a,b,c=map(int,input().split())
re=list(map(int,input().split()))
gr=list(map(int,input().split()))
mu=list(map(int,input().split()))
re.sort(reverse=1)
gr.sort(reverse=1)
mu.sort(reverse=1)
re=re[:x]
gr=gr[:y]
app=mu[:]
app.extend(re)
app.extend(gr)
app.sort(reverse=1)
app=app[:x+y]


print(sum(app))

Solution (Python):

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))

Solution (Python):
import sys
from collections import deque
readline = sys.stdin.readline

def main():
  x,y,a,b,c=map(int,readline().split())

  red=[int(i) for i in readline().split()]
  green=[int(i) for i in readline().split()]
  nc=sorted([int(i) for i in readline().split()], reverse=1)
  if a<x:
    red+=nc[:(x-a)]
    nc=nc[(x-a):]
  if b<y:
    green+=nc[:(y-b)]
    nc=nc[(y-b):]
  red=deque(sorted(red)[-x:])
  green=deque(sorted(green)[-y:])
  res=0
  
  def ppl(lst,i,t):
    if i>t:
      lst.popleft()
      return i
    else:
      return 0
    
  for i in nc:
    if (not red) and (not green):
      break
    if not red:
      tg=green[0]
      res+=ppl(green,i,tg)
    elif not green:
      tr=red[0]
      res+=ppl(red,i,tr)
    else:
      tr=red[0]
      tg=green[0]
      if tr<tg:
        res+=ppl(red,i,tr)
      else:
        res+=ppl(green,i,tg)
    
  print(res+sum(red)+sum(green))

main()

Solution (Python):
x, y, a,b,c = map(int,input().split())
pa = list(map(int, input().split()))
qb = list(map(int, input().split()))
rc = list(map(int, input().split()))

pa.sort(reverse=True)
qb.sort(reverse=True)
rc.sort(reverse=True)

pa = pa[:x]
qb = qb[:y]

_all = rc + pa + qb
_all.sort(reverse=True)

ans = 0
for i in range(x+y):
    ans += _all[i]

print(ans)

Solution (Python):
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
x, y, a, b, c = nm()
p = nl()
q = nl()
r = nl()
p.sort()
q.sort()
l = p[-x:] + q[-y:]
l.sort()
r.sort()
for i in range(c):
    if l[i] < r[-1]:
        l[i] = r.pop()
    else:
        break
print(sum(l))

Solution (Python):
x, y, a, b, c = map(int,input().split())
red = sorted(list(map(int,input().split())),reverse=True)[:x]
green = sorted(list(map(int,input().split())),reverse=True)[:y]
white = sorted(list(map(int,input().split())),reverse=True)

l = sorted(red+green+white,reverse=True)[:x+y]
print(sum(l))

Solution (Python):
(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:]))

Solution (Python):

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)[:X]
Q = sorted(Q, reverse=True)[:Y]
R = sorted(P+Q+R, reverse=True)[:X+Y]
print(sum(R))

Solution (Python):
X, Y, A, B, C = [int(i) for i in input().split()]
reds = sorted([int(i) for i in input().split()], reverse=True)
greens = sorted([int(i) for i in input().split()], reverse=True)
clears = sorted([int(i) for i in input().split()], reverse=True)

clear_acc = [0]

for i in clears:
    clear_acc.append(clear_acc[-1]+i)
        
reds = reds[:X]
greens = greens[:Y]

all_apples = sorted(reds+greens)

apple_sum = [sum(all_apples)]


for i in all_apples:
    apple_sum.append(apple_sum[-1]-i)
    

output = []

for i in range(min(X+Y, C+1)):
    output.append(apple_sum[i] + clear_acc[i])

print(max(output))

Solution (Python):


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()))

P = sorted(P, reverse=True)[:X]
Q = sorted(Q, reverse=True)[:Y]
R = sorted(P+Q+R, reverse=True)[:X+Y]

print(sum(R))

Solution (Python):


x, y, a, b, c = map(int, input().split())
p_list = list(map(int, input().split()))
p_list.sort(reverse=True)
q_list = list(map(int, input().split()))
q_list.sort(reverse=True)
r_list = list(map(int, input().split()))
r_list.sort(reverse=True)
p_list = p_list[0:x]
q_list = q_list[0:y]
p_count = 0
q_count = 0
r_count = 0
total = 0
for i in range(x + y):
    score_max = 0
    flag = 0
    if p_count < x:
        score = p_list[p_count]
        if score_max < score:
            score_max = score
            flag = 1
    if q_count < y:
        score = q_list[q_count]
        if score_max < score:
            score_max = score
            flag = 2
    if r_count < c:
        score = r_list[r_count]
        if score_max < score:
            score_max = score
            flag = 3
    if flag == 1:
        p_count += 1
    elif flag == 2:
        q_count += 1
    else:
        r_count += 1
    total += score_max
print(total)

Solution (Python):
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(int,input().split()))

p=p[:x]
q=q[:y]
print(sum(sorted(p+q+r,reverse=True)[:x+y]))

Solution (Python):
x, y, a, b, c = map(int,input().split())
red = list(map(int,input().split()))
green = list(map(int,input().split()))
non = list(map(int,input().split()))


red_trunc = sorted(red,reverse=True)[:x]
green_trunc = sorted(green,reverse=True)[:y]


total = non + red_trunc + green_trunc
total = sorted(total, reverse=True)
print(sum(total[:x+y]))

Solution (Python):
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)

total=sorted(p[:x]+q[:y]+r, reverse=True)

print(sum(total[:x+y]))

Solution (Python):
X,Y,A,B,C=map(int,input().split())
p=input().split()
P=[int(a) for a in p]
q=input().split()
Q=[int(a) for a in q]
r=input().split()
R=[int(a) for a in r]
P=sorted(P,reverse=True)
P=P[:X]
Q=sorted(Q,reverse=True)
Q=Q[:Y]
answers=P+Q+R
answers=sorted(answers,reverse=True)
answers=answers[:(X+Y)]
print(sum(answers))

Solution (Python):
X,Y,A,B,C = [int(i.strip()) for i in input().split(' ')]
p = [int(i.strip()) for i in input().split(' ')]
q = [int(i.strip()) for i in input().split(' ')]
r = [int(i.strip()) for i in input().split(' ')]

pd = sorted(p, reverse=True)
RED = pd[:X]
qd = sorted(q,reverse=True)
GREEN = qd[:Y]

ALL = r + RED +GREEN

ad = sorted(ALL,reverse=True)
print(sum(ad[:X+Y]))

Solution (Python):
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]
r += q[:y]
r.sort(reverse=True)

ans = sum(r[:x + y])
print(ans)

Solution (Python):
import sys
import math
import collections
from collections import deque

x, y, A, B, C = map(int, sys.stdin.readline().split())


a = list(map(int, sys.stdin.readline().split()))
b = list(map(int, sys.stdin.readline().split()))
c = list(map(int, sys.stdin.readline().split()))

a.sort(reverse = True)
b.sort(reverse = True)

for i in range(x):
    c.append(a[i])

for i in range(y):
    c.append(b[i])

c.sort(reverse = True)
ans = 0
for i in range(x+y):
    ans += c[i]

print(ans)

Solution (Python):
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()))
tmp = 0
p.sort(reverse=True)
p.append(0)
q.sort(reverse=True)
q.append(0)
r.sort(reverse=True)
r.append(0)
z = X+Y
e, f, g = 0, 0, 0
for i in range(z):
    if X>0 and ((p[e]>=q[f] and p[e]>=r[g]) or (Y==0 and p[e]>=r[g])):
        tmp = tmp+p[e]
        e += 1
        X -= 1
    elif Y>0 and ((q[f]>=p[e] and q[f]>=r[g]) or (X==0 and q[f]>=r[g])):
        tmp = tmp+q[f]
        f += 1
        Y -= 1
    elif r[g]>p[e] or r[g]>q[f]:
        tmp = tmp+r[g]
        g += 1
        
print(tmp)

Solution (Python):
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 = X + Y
R.sort(reverse=True)
P.sort(reverse=True)
Q.sort(reverse=True)

Z = P[:X]+Q[:Y]+R
Z.sort(reverse=True)
w = 0
for i in range(s):
    w += Z[i]
print(w)

Solution (Python):
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)

n_p = p[0:x]
n_q = q[0:y]

l = n_p +n_q +r
l.sort(reverse=True)

ans =0
for i in range(x+y):
    ans += l[i]

print(ans)

Solution (Python):


(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()]


sorted_P = sorted(P, reverse=True)
delicious_P = sorted_P[:X]


sorted_Q = sorted(Q, reverse=True)
delicious_Q = sorted_Q[:Y]



apples = delicious_P + delicious_Q + R
sorted_apples = sorted(apples, reverse=True)
remaining = sorted_apples[:X+Y]
print(sum(remaining))

Solution (Python):
mod = 10**9 + 7

def iip(listed = False):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <=0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n-r+1, n+1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r+1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        
        pass
    return ret


def inv(n, mod):
    return power(n, mod-2)

def power(n, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p//2) ** 2) % mod
    if p % 2 == 1:
        return (n * power(n, p-1)) % mod



def main():
    X, Y, A, B, C = iip()
    p = iip(listed=True)
    p.extend([0 for i in range(10**6)])
    q = iip(listed=True)
    q.extend([0 for i in range(10**6)])
    r = iip(listed=True)

    p.sort(reverse=True)
    q.sort(reverse=True)
    r.sort(reverse=True)

    red = p[:X]
    blue = q[:Y]
    red.sort()
    blue.sort()

    ir = 0
    ib = 0
    for nocolor in r:
        if min(red[ir], blue[ib]) < nocolor:
            if red[ir] < blue[ib]:
                red[ir] = nocolor
                if ir <= len(red)-2:
                    ir += 1
            else:
                blue[ib] = nocolor
                if ib <= len(blue)-2:
                    ib +=1
        else:
            break

    print(sum(red)+sum(blue))



    pass

if __name__ == "__main__":
    main()

Solution (Python):
x, y, a, b, c = list(map(int, input().split()))
ppp = list(map(int, input().split()))
qqq = list(map(int, input().split()))
rrr = list(map(int, input().split()))
ppp.sort(reverse=True)
qqq.sort(reverse=True)
ppqq = ppp[:x] + qqq[:y]
ppqq.extend(rrr)
ppqq.sort(reverse=True)
print(sum(ppqq[:x + y]))

Solution (Python):
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,reverse=True)
q = sorted(q,reverse=True)
r = sorted(r,reverse=True)
chk = p[:x]+q[:y]
chk = sorted(chk,reverse=True)
for i in range(c):
  if i < len(chk) and r[i] > chk[-(1+i)]:
    chk[-(1+i)] = r[i]   
print(sum(chk))

Solution (Python):
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()))

total = C
A.sort()
A.reverse()
B.sort()
B.reverse()

for i in range(X) :
  total.append(A[i])
  
for j in range(Y) :
  total.append(B[j])

total.sort()
total.reverse()
ans = sum(total[0 : X + Y])
print(ans)

Solution (Python):
x,y,a,b,c = (int(x) for x in input().split())
p = sorted((int(x) for x in input().split()), reverse=True)
q = sorted((int(x) for x in input().split()), reverse=True)
r = sorted((int(x) for x in input().split()), reverse=True)
ans = sum(p[:x]) + sum(q[:y])
cnt = 0
cnt_a = 0
cnt_b = 0
for cnt in range(c):
    if (x-1-cnt_a) < 0 and  y-1-cnt_b < 0:
        break
    pa = max(0, x-1-cnt_a)
    pb = max(0, y-1-cnt_b)
    if r[cnt] < p[pa] and r[cnt] < q[pb]:
        break
    if p[pa] > q[pb]:
        ans  = ans - q[pb] + r[cnt]
        cnt_b += 1
        q[pb] = r[cnt]
    elif p[pa] < q[pb]:
        ans = ans - p[pa] + r[cnt]
        cnt_a += 1
        p[pa] = r[cnt]
    else:
        j = 0
        while p[pa-j] == q[pb-j] and pa - j > -1 and pb - j > -1:
            j += 1
        if p[pa-j] > q[pb-j]:
            ans  = ans - q[pb] + r[cnt]
            cnt_b += 1
            q[pb] = r[cnt]
        elif p[pa-j] < q[pb-j]:
            ans = ans - p[pa] + r[cnt]
            cnt_a += 1
            p[pa] = r[cnt]
        elif x > y and x-1-cnt_a >= 0:
            ans = ans - p[pa] + r[cnt]
            cnt_a += 1
            p[pa] = r[cnt]
        elif y-1-cnt_b >= 0:
            ans  = ans - q[pb] + r[cnt]
            cnt_b += 1
            q[pb] = r[cnt]
        elif x-1-cnt_a >= 0:
            ans = ans - p[pa] + r[cnt]
            cnt_a += 1
            p[pa] = r[cnt]
        else:
            break
    
print(ans)

Solution (Python):
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)

pi = 0
qi = 0
ri = 0
ans = 0

for _ in range(X + Y):
    p = P[pi] if pi < X else 0
    q = Q[qi] if qi < Y else 0
    r = R[ri] if ri < C else 0

    if p > q:
        if p >= r:
            ans += p
            pi += 1
        else:
            ans += r
            ri += 1
    else:
        if q >= r:
            ans += q
            qi += 1
        else:
            ans += r
            ri += 1

print(ans)

Solution (Python):
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)[:x]
q=sorted(q,reverse=True)[:y]
print(sum(sorted(p+q+r, reverse=True)[:x+y]))

Solution (Python):
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)

p = p[:x]
q = q[:y]

s = p+q+r
s.sort(reverse=True)

print(sum(s[:(x+y)]))

Solution (Python):
X, Y, A, B, C = map(int, input().split())
Red = sorted(list(map(int, input().split())), reverse=True)
Grn = sorted(list(map(int, input().split())), reverse=True)
Wht = sorted(list(map(int, input().split())), reverse=True)

Mix = Red[:X] + Grn[:Y] + Wht
Mix = sorted(Mix, reverse=True)
ans = sum(Mix[:X+Y])
print(ans)

Solution (Python):
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)

px = p[:x]
qx = q[:y]

aps = sorted(px + qx + r, reverse=True)

print(sum(aps[0:x+y]))

Solution (Python):
import numpy as np
X, Y, A, B, C = map(int,input().split())
Reds = list(map(int, input().split()))
Greens = list(map(int, input().split()))
Ns = list(map(int, input().split()))

Reds = np.array(Reds)
Greens = np.array(Greens)
Ns = np.array(Ns)

Reds = np.sort(Reds)[::-1]
Greens = np.sort(Greens)[::-1]
Ns = np.sort(Ns)[::-1]

Full = np.append(Reds[:X], Greens[:Y])
Full = np.append(Full, Ns)
Full = np.sort(Full)[::-1]

sum = 0

for i in range(X+Y):
    sum += Full[i]

print(sum)

Solution (Python):
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()))

print(sum(sorted(sorted(p)[-x:] + sorted(q)[-y:] + r)[-(x+y):]))

Solution (Python):
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[:X]
q = q[:Y]
sumlist = list()
sumlist.extend(p)
sumlist.extend(q)
sumlist.extend(r)
sumlist.sort(reverse=True)
print(sum(sumlist[:X+Y]))

Solution (Python):
x,y,a,b,c = (int(x) for x in input().split())
list_p = list(map(int,input().split()))
list_q = list(map(int,input().split()))
list_r = list(map(int,input().split()))
list_p.sort()
list_q.sort()
list_p.reverse()
list_q.reverse()
for i in range(x):
    list_r.append(list_p[i])
for i in range(y):
    list_r.append(list_q[i])
list_r.sort()
list_r.reverse()
sum=0
for i in range(x+y):
    sum+=list_r[i]
print(sum)

Solution (Python):
import sys
from bisect import bisect_right, bisect_left

def to_cumsum(arr, pad=True):
    """
    1次元配列を累積和の1次元配列に変換する
    pad: 先頭に0の項を作る場合はTrue
    """
    cumsum = 0
    padding = 1 if pad else 0
    new = [0] * (len(arr) + padding)
    for i, e in enumerate(arr):
        cumsum += e
        new[i + padding] = cumsum
    return new

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


X, Y, A, B, C = MI()
P = LMI()
Q = LMI()
R = LMI()

P.sort(reverse=True)
Q.sort(reverse=True)

R.extend(P[:X])
R.extend(Q[:Y])

R.sort(reverse=True)
print(sum(R[:X + Y]))

Solution (Python):
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()))


rg = [(p, "r") for p in P] + [(q, "g") for q in Q]
rg.sort()
nc = R
nc.sort()

ans = 0
cnt_r, cnt_g, cnt_nc = 0, 0, 0


while cnt_r + cnt_g + cnt_nc < X + Y:

    if cnt_r == X:
        while rg[-1][1] == "r":
            rg.pop()

    if cnt_g == Y:
        while rg[-1][1] == "g":
            rg.pop()


    if len(nc) > 0 and nc[-1] > rg [-1][0]:
        tmp = nc.pop()
        cnt_nc += 1
    else:
        tmp, c = rg.pop()
        if c == "r":
            cnt_r += 1

        else:
            cnt_g += 1


    ans += tmp

print(ans)

Solution (Python):
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)

R0=P[:X]
R0.extend(Q[:Y])
R0.sort()
for i in range(C):
    if R0[i]<R[i]:
        R0[i]=R[i]
    else:
        break
print(sum(R0))

Solution (Python):
def resolve():
    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)
    pre = sorted(p[:X] + q[:Y])
    for i in range(min(X + Y, C)):
        if pre[i] < r[i]:
            pre[i] = r[i]
        else:
            break
    print(sum(pre))

resolve()

Solution (Python):
if __name__ == "__main__":

    X, Y, A, B, C = map(int, input().split())

    Red = list(map(int, input().split()))
    Red.sort()
    Red = Red[::-1]
    Red = Red[:X]
    Green = list(map(int, input().split()))
    Green.sort()
    Green = Green[::-1]
    Green = Green[:Y]
    NoColor = list(map(int, input().split()))

    A = Red + Green + NoColor
    
    A.sort(reverse=True)

    eaten = A[:X+Y]

    print(sum(eaten))

Solution (Python):
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()
l = p[-X:] + q[-Y:]
l.sort()

for i in range(min(X+Y,C)):
  if l[i] < r[-1]:
    l[i] = r.pop()


ans = sum(l)
print(ans)

Solution (Python):
from heapq import heapify, heappop
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    X,Y,A,B,C = map(int, readline().split())
    p = [-int(i) for i in readline().split()]
    q = [-int(i) for i in readline().split()]
    r = [-int(i) for i in readline().split()]

    p = sorted(p)[:X]
    q = sorted(q)[:Y]
    r.sort()
    
    Q = p + q + r
    heapify(Q)

    ans = 0
    for i in range(X+Y):
        ans -= heappop(Q)
        
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
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:]
pq = p + q
pq.sort()
r.sort()
N = X + Y
cnt = 0

from collections import deque
pq = deque(pq)
r = deque(r)

pq_max = pq.pop()
r_max = r.pop()
emp = deque()

for _ in range(N):
    if pq_max >= r_max:
        cnt += pq_max
        if pq == emp:
            pq_max = 0
        else:
            pq_max = pq.pop()
    else:
        cnt += r_max
        if r == emp:
            r_max = 0
        else:
            r_max = r.pop()

print(cnt)

Solution (Python):
import sys
input = sys.stdin.readline
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)
p=p[:x]
q=q[:y]
r=r+p+q
r.sort(reverse=True)
print(sum(r[:x+y]))

Solution (Python):
import sys
input = sys.stdin.readline
X, Y, A, B, C = (int(i) for i in input().split())
p = [[int(x), "A"] for x in input().split()]
q = [[int(x), "B"] for x in input().split()]
r = [[int(x), "C"] for x in input().split()]

apples = p+q+r



apples = sorted(apples, reverse=True)

ans = 0
pend = 0


for hapi, col in apples:
    if col == "C":
        pend += 1
        ans += hapi
    elif col == "A":
        if X > 0:
            ans += hapi
            X -= 1

    elif col == "B":
        if Y>0:
            ans += hapi
            Y -= 1

    if (X < 1 and Y < 1) or X+Y == pend:
        break
    
    

print(ans)

Solution (Python):
x,y,a,b,c=map(int,input().split())
p0=list(map(int,input().split()))
q0=list(map(int,input().split()))
r0=list(map(int,input().split()))
p1=sorted(p0)
q1=sorted(q0)
p2=[]
q2=[]
for i in range(x):
    p2.append(p1[-i-1])
for i in range(y):
    q2.append(q1[-i-1])
ringo0=p2+q2+r0
ringo1=sorted(ringo0,reverse=True)
s=0
for i in range(x+y):
    s=s+ringo1[i]
print(s)