Problem p02727 (python)

Fixed submission:
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)]))

Buggy submission (verdict: Runtime Error):
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(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

p_que1 = deque([])
q_que1 = deque([])
r_que1 = deque([])

p_que2 = deque([])
q_que2 = deque([])
r_que2 = deque([])

for i in range(a):
    p_que1.append(p[i])
    p_que2.append(p[i])
for i in range(b):
    q_que1.append(q[i])
    q_que2.append(q[i])
for i in range(c):
    r_que1.append(r[i])
    r_que2.append(r[i])

yamm_1 = 0
yamm_2 = 0

for i in range(x):
    if p_que1[0] >= r_que1[0]:
        ma = int(p_que1.popleft())
        yamm_1 += ma
    else:
        ma = int(r_que1.popleft())
        yamm_1 += ma

for i in range(y):
    if q_que1[0] >= r_que1[0]:
        ma = int(q_que1.popleft())
        yamm_1 += ma
    else:
        ma = int(r_que1.popleft())
        yamm_1 += ma


for i in range(x):
    if p_que2[0] >= r_que2[0]:
        ma = int(p_que2.popleft())
        yamm_2 += ma
    else:
        ma = int(r_que2.popleft())
        yamm_2 += ma

for i in range(y):
    if q_que2[0] >= r_que2[0]:
        ma = int(q_que2.popleft())
        yamm_2 += ma
    else:
        ma = int(r_que2.popleft())
        yamm_2 += ma


print(max(yamm_1, yamm_2))

Buggy submission (verdict: Runtime Error):
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(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

p_que = deque([])
q_que = deque([])
r_que = deque([])
for i in range(a):
    p_que.append(p[i])
for i in range(b):
    q_que.append(q[i])
for i in range(c):
    r_que.append(r[i])

yamm = 0

for i in range(x):
    if p_que[0] >= r_que[0]:
        ma = int(p_que.popleft())
        yamm += ma
    else:
        ma = int(r_que.popleft())
        yamm += ma

for i in range(y):
    if q_que[0] >= r_que[0]:
        ma = int(q_que.popleft())
        yamm += ma
    else:
        ma = int(r_que.popleft())
        yamm += ma

print(yamm)

Buggy submission (verdict: Runtime Error):
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(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

p_que = deque([])
q_que = deque([])
r_que = deque([])
for i in range(a):
    p_que.append(p[i])
for i in range(b):
    q_que.append(q[i])
for i in range(c):
    r_que.append(r[i])

yamm = 0

for i in range(x):
    if p_que[0] >= r_que[0]:
        ma = int(p_que.popleft())
        yamm += ma
    else:
        ma = int(q_que.popleft())
        yamm += ma

for i in range(y):
    if q_que[0] >= r_que[0]:
        ma = int(q_que.popleft())
        yamm += ma
    else:
        ma = int(r_que.popleft())
        yamm += ma

print(yamm)