TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
import sys
sys.setrecursionlimit(4100000)

x,y,a,b,c = map(int,input(),split())
p = sort(list(map(int,input(),split())))
q = sort(list(map(int,input(),split())))
r = list(map(int,input(),split()))
ans = 0

for k in range(1,x+1):
    r.append(p[-k])
for v in range(1,y+1):
    r.append(p[-v])

rs = sort(r)

for i in range(1,X+Y+1):
    ans += rs[-i]
print(str(ans))

x,y,a,b,c = map(int,input(),split())
p = sort(list(map(int,input(),split())))
q = sort(list(map(int,input(),split())))
r = list(map(int,input(),split()))
ans = 0

for k in range(1,x+1):
    r.append(p[-k])
for v in range(1,y+1):
    r.append(p[-v])

rs = sort(r)

for i in range(1,X+Y+1):
    ans += rs[-i]
print(str(ans))

import sys
sys.setrecursionlimit(4100000)

x,y,a,b,c = map(int,input().split())
p = sorted(list(map(int,input().split())))
q = sorted(list(map(int,input().split())))
r = list(map(int,input().split()))
ans = 0

for k in range(1,x+1):
    r.append(p[-k])
for v in range(1,y+1):
    r.append(q[-v])

rs = sorted(r)

for i in range(1,x+y+1):
    ans += rs[-i]
print(str(ans))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)

px = p[:X]
qy = q[:Y]
print(qy)
while r and min(px[-1], qy[1]) < r[0]:
  px.sort(reverse=True)
  qy.sort(reverse=True)
  if px[-1] < qy[-1]:
    px[-1] = r[0]
    r.pop(0)
  else:
    qy[-1] = r[0]
    r.pop(0)

print(sum(px) + sum(qy))

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()))
ans = sum(sorted(p + q + r, reverse=True)[:X + Y])
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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()))

all = p + q + r
all.sort(reverse=True)
print((all[: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 = list(map(int, input().split()))

all = p + q + r
all.sort(reverse=True)
print(sum(all[:X + Y]))

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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()));

umami = [[0]*2 for i in range(a+b+c)];

for i in range(a) :
    umami[i][0] = 0;
    umami[i][1] = p[i];
for i in range(b) :
    umami[a+i][0] = 1;
    umami[a+i][1] = q[i];
for i in range(c) :
    umami[a+b+i][0] = 2;
    umami[a+b+i][1] = r[i];

umami.sort(key=lambda x:x[1]);
umami.reverse();
i = 0;
j = 0;
numr = x;
numg = y;
ans = 0;

while i < x+y :
    if umami[j][0] == 0 and numr == 0 :
        j += 1;
    if umami[j][0] == 1 and numg == 0 :
        j += 1;
    else :
        if umami[j][0] == 0 :
            numr -= 1;
        if umami[j][0] == 1 :
            numg -= 1;
        ans += umami[j][1];
        i += 1;
    j += 1;
    print(numr,numg,ans);

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

umami = [[0]*2 for i in range(a+b+c)];
um = [0]*(x+y+c);

for i in range(a) :
    umami[i][0] = 0;
    umami[i][1] = p[i];

for i in range(b) :
    umami[a+i][0] = 1;
    umami[a+i][1] = q[i];
for i in range(c) :
    umami[a+b+i][0] = 2;
    umami[a+b+i][1] = r[i];

p.sort();
p.reverse();
q.sort();
q.reverse();
r.sort();
r.reverse();
for i in range(x) :
    um[i] = p[i];
for i in range(y) :
    um[i+x] = q[i];
for i in range(c) :
    um[i+x+y] = r[i];

um.sort();
um.reverse();

umami.sort(key=lambda x:x[1]);
umami.reverse();
i = 0;
j = 0;
numr = x;
numg = y;
ans = 0;

while i < x+y :
    if umami[j][0] == 0 and numr == 0 :
        j += 1;
    if umami[j][0] == 1 and numg == 0 :
        j += 1;
    else :
        if umami[j][0] == 0 :
            numr -= 1;
        if umami[j][0] == 1 :
            numg -= 1;
        ans += umami[j][1];
        i += 1;
        j += 1;

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

print(ans);

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
na, nb, a, b, c = map(int, input().split())
ab_list = [0 for i in range(na + nb)]
ab_list[:na] = sorted(list(map(int, input().split())), reverse=True)[:na]
ab_list[na:] = sorted(list(map(int, input().split())), reverse=True)[:nb]
c_list = sorted(list(map(int, input().split())), reverse=True)[:min(na + nb, c)]

ab_list.sort()

c_max = c_list[-1]
ab_index = 0
for index in range(len(ab_list)):
    if c_max <= ab_list[index]:
        ab_index = index
        break

ab_list[:ab_index] = sorted(ab_list[:ab_index] + c_list[-ab_index:])[:ab_index]

print(sum(ab_list))

na, nb, a, b, c = map(int, input().split())
ab_list = [0 for i in range(na + nb)]
ab_list[:na] = sorted(list(map(int, input().split())), reverse=True)[:na]
ab_list[na:] = sorted(list(map(int, input().split())), reverse=True)[:nb]
ab_list += sorted(list(map(int, input().split())), reverse=True)[:min(na + nb, c)]

ab_list.sort(reverse=True)

print(sum(ab_list[:na + nb]))

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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.sort(reverse=True)
q.sort(reverse=True)
for i in range(x): r.append(p[i])
for i in range(y): r.append(q[i])
r.sort(reverse=True)
print(sum(r[:x+y])

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)

A=P[:X]+Q[:Y]+R

A.sort(reverse=True)

print(A[X+Y])

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

A=P[:X]+Q[:Y]+R

A.sort(reverse=True)

print(A[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)

A=P[:X]+Q[:Y]+R

A.sort(reverse=True)

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

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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(rr[-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))

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
x, y, a, b, c = map(int, input().split())
arrayP = list(map(int, input().split()))
arrayQ = list(map(int, input().split()))
arrayR = list(map(int, input().split()))
arrayP.sort(reverse=True)
arrayQ.sort(reverse=True)
arrayR.sort(reverse=True)
arrayAns = []
for i in range(x):
    arrayAns.append(int(arrayP[i]))
for i in range(y):
    arrayAns.append(int(arrayQ[i]))
arrayAns.sort()
for i in range(len(arrayAns)):
    if arrayAns[i] <= int(arrayR[i]):
        arrayAns[i] = int(arrayR[i])
    else:
        break
print(sum(arrayAns))

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




Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)


ans = 0

while (p[0] > r[0]):
    ans += p.pop(0)
    x -= 1
    if (x == 0):
        break
while (q[0] > r[0]):
    ans += q.pop(0)
    y-=1
    if (y == 0):
        break

if (x == 0 and y == 0):
    print(ans)
else:
    aps = sorted(p[0: x] + q[0: y] + r[0: x + y], reverse=True)
    print(aps)
    print(ans+sum(aps[0:x+y]))



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



Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)

alist = []
ans = 0

for i in range(X):
    alist.append(p[i])
    
for j in range(Y):
    alist.append(q[j])
    
alist.sort(reverse=True)
ans = sum(alist)

a2 = [alist[0]]
r2 = [r[0]]

for i in range(1,len(alist)):
    a2.append(alist[i]+a2[i-1])
    r2.append(r[i]+r2[i-1])

ans = a2[-1]

for i in range(C-1):
    ans = max(ans,a2[i]+r2[C-i-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(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

alist = []
ans = 0

for i in range(X):
    alist.append(p[i])
    
for j in range(Y):
    alist.append(q[j])
    
for k in range(C):
    alist.append(r[k])
    
alist.sort(reverse=True)
    
for k in range(X+Y):
    ans += alist[k]

print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import sys
#from collections import deque
input = sys.stdin.buffer.readline

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)
ans = p[:x]
ans[x:x] = q[:y]
ans=sorted(ans)
#print(ans)
i = 0
result = 0
for A in ans:
    if A < r[i]:
        result += r[i]
        if i < c:
            i += 1
        continue
    result += A
print(result)

import sys
#from collections import deque
input = sys.stdin.buffer.readline

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
#n,x,y=map(int,input())

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.sort()
q.sort()
p=deque(p[a-x:])
q=deque(q[b-y:])
r.sort()
for ri in r:
    if ri > p[0] and q[0] >= p[0]:
        p.popleft()
        p.append(ri)
        p.sort()
        continue
    if ri > q[0] and p[0] >= q[0]:
        q.popleft()
        q.sort()
        q.append(ri)
print(sum(p)+sum(q))

"""
1 2 2 2 1
2 4
5 1
3
->12
2 2 2 2 2
8 6
9 1
2 1
->25
"""



#n,x,y=map(int,input())

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.sort()
q.sort()
p=deque(p[a-x:])
q=deque(q[b-y:])
r.sort()
for ri in r:
    if ri > p[0] and q[0] >= p[0]:
        p.popleft()
        print(ri)
        p.append(ri)
        continue
    if ri > q[0] and p[0] >= q[0]:
        q.popleft()
        print(ri)
        q.append(ri)
print(sum(p)+sum(q))

"""
1 2 2 2 1
2 4
5 1
3
->12
2 2 2 2 2
8 6
9 1
2 1
->25
"""



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


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import bisect
X, Y, A, B, C = map(int, input().split())
red = [int(x) for x in input().split()]
gre = [int(x) for x in input().split()]
non = [int(x) for x in input().split()]
red.sort(reverse=True)
gre.sort(reverse=True)
non.sort()
ans = red[:X] + gre[:Y]
ans.sort(reverse=True)
if non[-1] > ans[-1]:
    c = non[-1]
    index = bisect_right_reverse(ans, c)
    ans.insert(index, c)
    non.pop(-1)
    ans.pop(-1)
print(sum(ans))

X, Y, R, G, N = map(int, input().split())
r = [int(x) for x in input().split()]
g = [int(x) for x in input().split()]
n = [int(x) for x in input().split()]
r = sorted(r)[R-X:]
g = sorted(g)[G-Y:]

apple = r + g + n
apple = sorted(apple)[len(apple)-(X+Y):]
print(sum(apple))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import sys
import heapq

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

P = list(map(int, readline().split()))
Q = list(map(int, readline().split()))
R = list(map(int, readline().split()))

print(len(P), len(Q), len(R))

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

heapq.heapify(P)
heapq.heapify(Q)

print(len(P), len(Q), len(R))

for r in R:
    p = heapq.heappop(P)
    q = heapq.heappop(Q)

    if p <= q and p < r:
        heapq.heappush(P, r)
        heapq.heappush(Q, q)
    elif q < r:
        heapq.heappush(Q, r)
        heapq.heappush(P, p)
    else:
        heapq.heappush(P, p)
        heapq.heappush(Q, q)

print(sum(P) + sum(Q))

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

P = sorted(map(int, readline().split()),reverse=True)
Q = sorted(map(int, readline().split()),reverse=True)
R = sorted(map(int, readline().split()),reverse=True)

lis = P[:X] + Q[:Y] + R

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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()))

goukei = X + Y
delicious = 0
red = 0
green = 0


def max_pop(p):
    pidx = p.index(max(p))
    maxp = p.pop(pidx)
    return maxp


maxp = max_pop(p)
maxq = max_pop(q)
maxr = max_pop(r)
maxdelis = [maxp, maxq, maxr]
for i in range(goukei):
    maxdeli = max(maxdelis)
    idx = maxdelis.index(max(maxdelis))
    delicious += maxdeli
    if idx == 0:
        red += 1
        if red == X:
            maxdelis[0] = 0
        else:
            maxdelis[0] = max_pop(p)
    elif idx == 1:
        green += 1
        if green == X:
            maxdelis[1] = 0
        else:
            maxdelis[1] = max_pop(q)
    else:
        maxdelis[2] = max_pop(r)

print(delicious)


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)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)
pp = p[:x]
qq = q[:y]
rr = r[:(x+y)]
ppqq = pp + qq
ppqq.sort()
for i in range(len(ppqq)):
  if ppqq[i] < rr[0]:
    ppqq[i] = rr[0]
    del rr[0]
print(sum(ppqq))

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)
pp = p[:x]
qq = q[:y]
if x+y <= c:
  rr = r[:(x+y)]
else:
  rr = r
ppqq = pp + qq
ppqq.sort()
for i in range(len(ppqq)):
  if ppqq[i] < rr[0]:
    ppqq[i] = rr[0]
    del rr[0]
print(sum(ppqq))

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)
pp = p[:x]
qq = q[:y]
if x+y <= c:
  rr = r[:(x+y)]
else:
  rr = r
ppqqrr = pp + qq + rr
ppqqrr.sort(reverse = True)
print(sum(ppqqrr[:x+y]))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import sys
sys.setrecursionlimit(10**6)


mod = 10 ** 9 + 7
N = 2* 10 ** 5  
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)

def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % mod
  

def dfs(v, p=-1):

    # print(v, p, [x + 1 for x in E[v]])
    
    dp_l = 1  
    size_l = 1 

    
    for u in E[v]:
        
        
        if u == p:
            continue

        d, s = dfs(u, v)
        d %= mod
        size_l += s
        dp_l = dp_l * d * cmb(size_l-1, s) % mod

    dp[v] = dp_l
    size[v] = size_l
        
    return (int(dp_l), size_l)
  
def bfs(v, p=-1):
    
    for u in E[v]:
        if u == p:
            continue
        
        
        

        partial_v = int(dp[v] / dp[u] / cmb(N - 1, size[u]))
        
        
        

        dp_l = dp[u] * partial_v * cmb(N-1, size[u]-1)
        
        dp[u] = dp_l
    
        bfs(u,v)


N = int(input())
E = [[] for _ in range(N)]

for _ in range(N-1):
    a, b = map(int, input().split())
    E[a-1].append(b-1)
    E[b-1].append(a-1)
      
dp = [1] * N
size = [1] * N


dfs(0)

bfs(0)

for i in range(N):
    print(dp[i])

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

p = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
r = [int(x) for x in input().split()]

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

apples = []
apples.extend(p[:X])
apples.extend(q[:Y])

apples.sort(reverse=True)
apples.extend(r)

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def main():
    X, Y, A, B, C = [int(i) for i in input().split()]
    red = [int(i) for i in input().split()]
    blue = [int(i) for i in input().split()]
    noc = [int(i) for i in input().split()]
    red = sorted(red)[-X:]
    blue = sorted(blue)[-Y:]
    rb = sorted(red + blue)
    score = sum(rb)
    noc = sorted(noc)[::-1]

    exit()
    s_noc = 0
    s_rb = 0
    for i in range(min(A+B, C)):
        if rb[i] > noc[i]:
            break
        s_noc += noc[i]
        s_rb += rb[i]

    print(score + s_noc - s_rb)


if __name__ == '__main__':
    main()



def main():
    X, Y, A, B, C = [int(i) for i in input().split()]
    red = [int(i) for i in input().split()]
    blue = [int(i) for i in input().split()]
    noc = [int(i) for i in input().split()]
    red = sorted(red)[-X:]
    blue = sorted(blue)[-Y:]
    rb = sorted(red + blue)
    score = sum(rb)
    noc = sorted(noc)[::-1]

    s_noc = 0
    s_rb = 0
    for i in range(min(len(rb), len(noc))):
        if rb[i] > noc[i]:
            break
        s_noc += noc[i]
        s_rb += rb[i]

    print(score + s_noc - s_rb)


if __name__ == '__main__':
    main()



Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)

Red = p[:X]
Green = q[:Y]

Apple = sorted(Red + Green)
for i in range(C):
    print(Apple[i], r[i])
    if Apple[i] < r[i]:
        Apple[i] = r[i]
print(sum(Apple))

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

Red = p[:X]
Green = q[:Y]

h = sorted(Red + Green)
heapq.heapify(h)
for i in r:
    heapq.heappushpop(h, i)
print(sum(h))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
X, Y, A, B, C = 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_list = P[:X]
ANS_list.extend(Q[:Y])
ANS_list.sort()
c = 0
for i in range(len(R)):
    if ANS_list[i] >= R[i]:
        break
    c+=1

if i!=0:
    ANS_list[:c] = R[:c]

print(sum(R[:c])+sum(ANS_list[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()))
P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

ANS_list = P[:X]
ANS_list.extend(Q[:Y])
ANS_list.sort()
c = 0
for i in range(len(R)):
  if ANS_list[i] >= R[i]:
    break
  c+=1

if i!=0:
  ANS_list[:c] = R[:c]
print(sum(R[:c])+sum(ANS_list[c:]))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from collections import deque
x,y,a,b,c = map(int,input().split())
p1 = list(map(int,input().split()))
q1 = list(map(int,input().split()))
r1 = list(map(int,input().split()))
ans = []
p1.sort(reverse=1)
q1.sort(reverse=1)
r1.sort(reverse=1)


p=deque(p1[0:x])
q=deque(q1[0:y])
r=deque(r1[0:x+y])

lp = p.pop()
lq = q.pop()

rr = r.popleft()

while 1:
    print(lp,lq,rr)
    if x > 0 and lp <= lq or y == 0:
        if lp >= rr:
            ans.append(lp)
            
        else:
            ans.append(rr)
            r.append(0)
            rr = r.popleft()
        if x > 1:
                lp = p.pop()
        x -= 1
    if y > 0:
        if lq >= rr:
            ans.append(lq)
            
        else:
            ans.append(rr)
            r.append(0)
            rr = r.popleft()
        if y > 1:
                lq = q.pop()
        y -= 1
    if x == 0 and y == 0:
        print(sum(ans))
        exit()



from collections import deque
x,y,a,b,c = map(int,input().split())
p1 = list(map(int,input().split()))
q1 = list(map(int,input().split()))
r1 = list(map(int,input().split()))
ans = []
p1.sort(reverse=1)
q1.sort(reverse=1)
r1.sort(reverse=1)


p=deque(p1[0:x])
q=deque(q1[0:y])
r=deque(r1[0:x+y])

lp = p.pop()
lq = q.pop()

rr = r.popleft()

while 1:
#     print(lp,lq,rr)
    if (x > 0 and lp <= lq) or y == 0:
        if lp >= rr:
            ans.append(lp)
            
        else:
            ans.append(rr)
            r.append(0)
            rr = r.popleft()
        if x > 1:
                lp = p.pop()
        x -= 1
    else:
        if lq >= rr:
            ans.append(lq)
            
        else:
            ans.append(rr)
            r.append(0)
            rr = r.popleft()
        if y > 1:
                lq = q.pop()
        y -= 1
    if x == 0 and y == 0:
        print(sum(ans))
        exit()



Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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

for i in range(X):
    if A[-1] >= C[-1]:
        ans += A[-1]
        A.pop()
    else:
        ans += C[-1]
        C.pop()

for i in range(Y):
    if B[-1] >= C[-1]:
        ans += B[-1]
        B.pop()
    else:
        ans += C[-1]
        C.pop()
        
print(ans)

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)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
x,y,a,b,c = (int(x) for x in input().split())

from bisect import insort

p_list = []
q_list = []
r_list = []

for value in input().split():
  insort(p_list,  int(value))

for value in input().split():
  insort(q_list,  int(value))
  
for value in input().split():
  insort(r_list,  int(value))
  
red = 0
green = 0
white = 0

sum_num = 0

print(sum_num)
for i in range(1,x+y+1):
  if red < x:
  	red_num = p_list[(red*-1)-1]
  else:
    red_num = 0
  if green < y:
  	green_num = q_list[(green*-1)-1]
  else:
    green_num = 0
  if white < c:
  	white_num = r_list[(white*-1)-1]
  else:
    white_num = 0
  
  max_p = max([red_num,green_num,white_num])
  sum_num += max_p
  if max_p == white_num:
    white += 1
  elif max_p == red_num:
    red += 1
  elif max_p == green_num:
    green += 1

x,y,a,b,c = (int(x) for x in input().split())

from bisect import insort

p_list = list(map(int,input().split()))
q_list = list(map(int,input().split()))
r_list = list(map(int,input().split()))


p_list.sort()
q_list.sort()
r_list.sort()

red = 0
green = 0
white = 0

sum_num = 0

for i in range(1,x+y+1):
  if red < x:
  	red_num = p_list[(red*-1)-1]
  else:
    red_num = 0
  if green < y:
  	green_num = q_list[(green*-1)-1]
  else:
    green_num = 0
  if white < c:
  	white_num = r_list[(white*-1)-1]
  else:
    white_num = 0
  
  max_p = max([red_num,green_num,white_num])
  sum_num += max_p
  if max_p == white_num:
    white += 1
  elif max_p == red_num:
    red += 1
  elif max_p == green_num:
    green += 1

print(sum_num)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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.extend(qlist)
plist.sort()

rlist.sort(reverse=True)

n = min(len(plist),len(rlist))
slist = plist[0:x+y-1]
ulist = plist[0:x+y-1]
slist[0] = rlist[0]
i = 1

while i < n and sum(slist)>sum(ulist):
  slist[i]=rlist[i]
  ulist[i-1]=rlist[i-1]
  i += 1

print(sum(slist))
  

x,y,a,b,c = map(int, input().split(" "))
plist= sorted(list(map(int, input().split(" "))),reverse=True)[0:x]
qlist= sorted(list(map(int, input().split(" "))),reverse=True)[0:y]
rlist= sorted(list(map(int, input().split(" "))),reverse=True)

plist.extend(qlist)
plist.sort()
n = min(x+y,len(rlist))
i = 0

while i < n and rlist[i]>plist[i]:
  i += 1
if i == 0:
  print(sum(plist))
else:
  print(sum(plist[i:x+y])+sum(rlist[0:i]))


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):

import numpy as np
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)
C.sort(reverse=True)

A = A[0:X]
B = B[0:Y]
#C = np.array(C)

arr = A+B

flag = 1

while(flag):
  tmp = 0
  _min = min(arr)
  _max = max(C)
  if _min <= _max:
    arr[arr.index(_min)] = _max
  else:
    flag = 0
"""
_min = min(arr)
C = C[C>_min]

for c in C:
  _min = min(arr)
  if c >= _min:
    arr[arr.index(_min)] = c


"""
print(sum(arr))

import numpy as np
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)
C.sort(reverse=True)

A = A[0:X]
B = B[0:Y]
D = A+B+C

D.sort(reverse=True)

D = D[0:X+Y]
print(sum(D))

Verdicts: Time Limit Exceeded

Accepted
Problem: 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.

Submission attempts (in order):
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()))
L = p + r
L.sort(reverse = True)
ans = 0
for i in range(X):
  ans += int(L[i])
for i in range(X):  
  L.remove(L[i])
set(L) = set(L)-set(p)  
M = q + list(L)
M.sort(reverse = True)
abc = 0  
for i in range(Y):
  abc += int(M[i])
print(ans + abc)  

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



Verdicts: Runtime Error

Accepted