Problem p03078 (python)

Fixed submission:
X, Y, Z, K = map(int, input().split())
A, B, C = [sorted(list(map(int, input().split())))[:: -1][: K] for _ in range(3)]
D = []
for ai in A:
    for bi in B:
        D.append(ai + bi)

D = sorted(D)[:: -1][: K]

res = []
for di in D:
    for ci in C:
        res.append(di + ci)

res = sorted(res)[:: -1][: K]

for ans in res:
    print(ans)

Buggy submission (verdict: Runtime Error):
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
D = [0] * (X * Y)
E = [0] * (K * Z)
m, n = 0, 0

for i in range(X):
    for j in range(Y):
        D[m] = A[i] + B[j]
        m += 1

for k in range(K):
    for l in range(Z):
        E[n] = sorted(D)[:: -1][: K][k] + C[l]
        n += 1

for p in range(K):
    print(sorted(E)[:: -1][p])

Buggy submission (verdict: Runtime Error):
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
D = [0] * (X * Y)
F = [0] * (X * Y * Z)
m, n = 0, 0

for i in range(X):
	for j in range(Y):
		D[m] = A[i] + B[j]
		m += 1

Dsort = sorted(D)[:: -1]
E = Dsort[: K]

for k in range(len(E)):
	for l in range(Z):
		F[n] = E[k] + C[l]
		n += 1

for p in range(K):
	print(sorted(F)[:: -1][p])

Buggy submission (verdict: Runtime Error):
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
D = [0] * (X * Y)
F = [0] * (X * Y * Z)
m, n = 0, 0
for i in range(X):
	for j in range(Y):
		D[m] = A[i] + B[j]
		m += 1

Dsort = sorted(D)[:: -1]
E = Dsort[: K]

for k in range(len(E)):
	for l in range(Z):
		F[n] = E[k] + C[l]
		n += 1

G = sorted(F)[:: -1]

for p in range(K):
	print(G[p])

Buggy submission (verdict: Runtime Error):
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
W = X * Y * Z
D = [0] * W
m = 0
for i in range(X):
	for j in range(Y):
		for k in range(Z):
			D[m] = A[i] + B[j] + C[k]
			m = m + 1
E = sorted(D)[:: -1]
for n in range(K):
	print(E[n])

Buggy submission (verdict: Runtime Error):
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
W = X * Y * Z
D = [0] * W
m = 0
for i in range(X):
	for j in range(Y):
		for k in range(Z):
			D[m] = A[i] + B[j] + C[k]
			m = m + 1
E = sorted(D, reverse = True)
for n in range(K):
	print(E[n])

Buggy submission (verdict: Runtime Error):
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
W = X * Y * Z
D = [0] * W
m = 0
for i in range(X):
	for j in range(Y):
		for k in range(Z):
			D[m] = A[i] + B[j] + C[k]
			m = m + 1
print(D)
E = sorted(D, reverse = True)
for n in range(K):
	print(E[n])

Buggy submission (verdict: Runtime Error):
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
W = X * Y * Z
D = [0] * W
m = 0
for i in range(X):
	for j in range(Y):
		for k in range(Z):
			D[m] = A[i] + B[j] + C[k]
			m = m + 1
print(D)
E = sorted(D, reverse = True)
for n in range(K):
	print(E[n])