Problem p02727 (python)

Fixed submission:
import sys
import numpy as np
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
X, Y, A, B, C = [int(x) for x in input().strip().split()]
p = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:X]
q = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:Y]
r = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:min(C, X+Y)]

pq = np.hstack((p, q))
pq.sort()
ri = 0
for i, t in enumerate(pq):
    if t < r[ri]:
        pq[i] = r[ri]
        ri += 1
    if ri == len(r):
        break
print(sum(pq))

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
X, Y, A, B, C = [int(x) for x in input().strip().split()]
p = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:X]
q = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:Y]
r = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:min(C, X+Y)]

pq = np.hstack((p, q, r))
pq.sort()
print(sum(pq[-(X+Y):]))

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
X, Y, A, B, C = [int(x) for x in input().strip().split()]
p = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:X]
q = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:Y]
r = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:min(C, X+Y)]

pq = np.hstack((p, q))
pq.sort()
ri = 0
for i, t in enumerate(pq):
    if t < r[ri]:
        pq[i] = r[ri]
        ri += 1
print(sum(pq))

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
X, Y, A, B, C = [int(x) for x in input().strip().split()]
p = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:X]
q = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:Y]
r = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:min(C, X+Y)]

pq = np.hstack((p, q))
pq.sort()
pq = pq[::-1]
ri = 0
for i, t in enumerate(pq):
    if t < r[ri]:
        pq[i] = r[ri]
        ri += 1
print(sum(pq))

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
X, Y, A, B, C = [int(x) for x in input().strip().split()]
p = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:X]
q = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:Y]
r = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:min(C, X+Y)]

pq = np.hstack((p, q))
ri = 0
for i, t in enumerate(pq):
    if t < r[ri]:
        pq[i] = r[ri]
        ri += 1
print(sum(pq))

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
X, Y, A, B, C = [int(x) for x in input().strip().split()]
p = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:X]
q = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:Y]
r = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:min(C, X+Y)]

pi, qi, ri = X-1, Y-1, 0
tp, tq, tr = p[pi], q[qi], r[ri]
ans = 0
while pi >= 0 or qi >= 0:
    if tp >= tr and  tq >= tr:
        break
    elif tp < tr and tq < tr:
        if tp < tq:
            p[pi] = r[ri]
            pi -= 1
            ri += 1
        else:
            q[qi] = r[ri]
            qi -= 1
            ri += 1
    elif tp < tr or tq < tr:
        if tp < tr:
            p[pi] = r[ri]
            ri += 1
            pi -= 1
            tp = p[pi]
        else:
            q[qi] = r[ri]
            ri += 1
            qi -= 1
            tq = q[qi]
    else:
        break
    if ri == len(r):
        break

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

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
X, Y, A, B, C = [int(x) for x in input().strip().split()]
p = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:X]
q = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:Y]
r = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:min(C, X+Y)]

pi, qi, ri = X-1, Y-1, 0
tp, tq, tr = p[pi], q[qi], r[ri]
ans = 0
while pi >= 0 or qi >= 0:
    if tp >= tr and  tq >= tr:
        break
    elif tp < tr and tq < tr:
        if tp < tq:
            p[pi] = r[ri]
            pi -= 1
            ri += 1
        else:
            q[qi] = r[ri]
            qi -= 1
            ri += 1
    elif tp < tr or tq < tr:
        if tp < tr:
            p[pi] = r[ri]
            ri += 1
            pi -= 1
            tp = p[pi]
        else:
            q[qi] = r[ri]
            ri += 1
            qi -= 1
            tq = q[qi]
    else:
        break

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

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
X, Y, A, B, C = [int(x) for x in input().strip().split()]
p = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:X]
q = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:Y]
r = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:min(C, X+Y)]

print(p, q, r)
pi, qi, ri = X-1, Y-1, 0
tp, tq, tr = p[pi], q[qi], r[ri]
ans = 0
while pi >= 0 or qi >= 0:
    if tp >= tr and  tq >= tr:
        break
    elif tp < tr and tq < tr:
        if tp < tq:
            p[pi] = r[ri]
            pi -= 1
            ri += 1
        else:
            q[qi] = r[ri]
            qi -= 1
            ri += 1
    elif tp < tr or tq < tr:
        if tp < tr:
            p[pi] = r[ri]
            ri += 1
            pi -= 1
            tp = p[pi]
        else:
            q[qi] = r[ri]
            ri += 1
            qi -= 1
            tq = q[qi]
    else:
        break

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

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
X, Y, A, B, C = [int(x) for x in input().strip().split()]
p = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:X]
q = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:Y]
r = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:X+Y]

pi, qi, ri = X-1, Y-1, 0
tp, tq, tr = p[pi], q[qi], r[ri]
ans = 0
while pi >= 0 or qi >= 0:
    if tp >= tr and  tq >= tr:
        break
    elif tp < tr and tq < tr:
        if tp < tq:
            p[pi] = r[ri]
            pi -= 1
            ri += 1
        else:
            q[qi] = r[ri]
            qi -= 1
            ri += 1
    elif tp < tr or tq < tr:
        if tp < tr:
            p[pi] = r[ri]
            ri += 1
            pi -= 1
            tp = p[pi]
        else:
            q[qi] = r[ri]
            ri += 1
            qi -= 1
            tq = q[qi]
    else:
        break

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

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
X, Y, A, B, C = [int(x) for x in input().strip().split()]
p = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:X]
q = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:Y]
r = np.array(sorted([int(x) for x in input().strip().split()], reverse=True))[:X+Y]

pi, qi, ri = X-1, Y-1, 0
tp, tq, tr = p[pi], q[qi], r[ri]
ans = 0
while pi >= 0 or qi >= 0:
    if tp >= tr and  tq >= tr:
        break
    elif tp < tr and tq < tr:
        if tp < tq:
            p[pi] = r[ri]
            pi -= 1
            ri += 1
        else:
            q[qi] = r[ri]
            qi -= 1
            ri += 1
    else:
        if tp < tr:
            p[pi] = r[ri]
            ri += 1
            pi -= 1
            tp = p[pi]
        else:
            q[qi] = r[ri]
            ri += 1
            qi -= 1
            tq = q[qi]

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