Problem: The Patisserie AtCoder sells cakes with number-shaped candles. There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively. Each cake has an integer value called _deliciousness_ , as follows:    * The deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X.   * The deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y.   * The deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z.  Takahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123.   There are X \times Y \times Z such ways to choose three cakes.   We will arrange these X \times Y \times Z ways in descending order of the sum of the deliciousness of the cakes.   Print the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list.

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

e = [a_i + b_j for b_j in b for a_i in a]
e.sort(reverse=True)

ans = [e_i + c_j for c_j in c[:k] for e_i in e[:k]]
ans.sort(reverse=True)

print(ans[:k])

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()))
c.sort(reverse=True)

e = [a_i + b_j for b_j in b for a_i in a]
e.sort(reverse=True)

ans = [e_i + c_j for c_j in c[:k] for e_i in e[:k]]
ans.sort(reverse=True)

print(ans[:k])

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

e = [a_i + b_j for b_j in b for a_i in a]
e = sorted(e, reverse=True)

ans = [e_i + c_j for c_j in c[:k] for e_i in e[:k]]
ans.sort(reverse=True)

print(ans[:k])

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

e = [a_i + b_j for b_j in b for a_i in a]
e = sorted(e, reverse=True)[:k]

ans = [e_i + c_j for c_j in c for e_i in e]
ans.sort(reverse=True)

print(ans[:k])

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

e = [a_i + b_j for b_j in b for a_i in a]
e = sorted(e, reverse=True)

ans = [e_i + c_j for c_j in c[:k] for e_i in e[:k]]
ans.sort(reverse=True)

print(ans[:k])

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

e = []
for a_i in a:
    for b_j in b:
        e.append(a_i + b_j)
e = sorted(e, reverse=True)

ans = []
for e_i in e[:k+1]:
    for c_j in c:
        ans.append(e_i + c_j)

ans.sort(reverse=True)
print(ans[:k])

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

e = [a_i + b_j for b_j in b for a_i in a]
e = sorted(e, reverse=True)

ans = [e_i + c_j for c_j in c for e_i in e]
ans.sort(reverse=True)

print(ans[:k])

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()))
c.sort(reverse=True)

e = [a_i + b_j for b_j in b for a_i in a]
e.sort(reverse=True)

ans = [e_i + c_j for c_j in c[:k] for e_i in e[:k]]
ans.sort(reverse=True)

for i in ans[:k]:
    print(i)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted