input stringlengths 20 127k | target stringlengths 20 119k | problem_id stringlengths 6 6 |
|---|---|---|
import itertools
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
result = [a + b + c for (a,b,c) in list(itertools.product(A, B, C))]
result.sort(reverse = True)
for i in range(K):
print((result[i])) | import itertools
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
result = [a + b for (a,b) in list(itertools.product(A, B))]
result.sort(reverse = True)
result = [s + c for (s,c) in list(itertools.product(resul... | p03078 |
X, Y, Z, K = list(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)
ans = [A[i]+B[j]+C[k] for i in range(X) for j in range(Y) for k in range(Z) if (i+1)*(j+1)*(k+... | X, Y, Z, K = list(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)
t =[]
for i in range(X):
for j in range(Y):
for k in range(Z):
if ... | p03078 |
from heapq import nlargest
x,y,z,k=list(map(int,input().split()))
A,B,C=[list(map(int,input().split()))for _ in[0]*3]
E=nlargest(k,(a+b+c for a in A for b in B for c in C))
for i in E:
print(i)
| from heapq import nlargest
x,y,z,k=list(map(int,input().split()))
A,B,C=[list(map(int,input().split()))for _ in[0]*3]
D=nlargest(k,(a+b for a in A for b in B ))
E=nlargest(k,(d+c for c in C for d in D ))
for i in E:
print(i)
| p03078 |
#coding:utf-8
import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True
def main():
X,Y,Z,K = LMIIS()
A = L... | #coding:utf-8
import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True
def main():
X,Y,Z,K = LMIIS()
A = L... | p03078 |
#coding:utf-8
import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True
def main():
X,Y,Z,K = LMIIS()
A = L... | #coding:utf-8
import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True
def main():
X,Y,Z,K = LMIIS()
A = L... | p03078 |
from collections import deque
X, Y, Z, K = list(map(int,input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
out = deque()
for i in range(X):
for j in range(Y):
for k in range(Z):
out.append(A[i]+B[j]+C[k])
ou... | from collections import deque
X, Y, Z, K = list(map(int,input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
out = deque()
out2 = deque()
for i in range(X):
for j in range(Y):
out.append(A[i]+B[j])
out = list(out)
out.so... | p03078 |
from collections import deque
X, Y, Z, K = list(map(int,input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
out = deque()
out2 = deque()
for i in range(X):
for j in range(Y):
out.append(A[i]+B[j])
out = list(out)
out.so... | from collections import deque
X, Y, Z, K = list(map(int,input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
out = deque()
out2 = deque()
for i in range(X):
for j in range(Y):
out.append(A[i]+B[j])
out = sorted(out, rever... | p03078 |
from functools import lru_cache
numbers = input().split()
x = input().split()
y = input().split()
z = input().split()
k = int(numbers[3])
x.sort(reverse=True)
y.sort(reverse=True)
z.sort(reverse=True)
answer = []
for i in x:
for j in y:
for m in z:
price = int(i)+int(j)+in... | numbers = input().split()
x = input().split()
y = input().split()
z = input().split()
k = int(numbers[3])
answer = []
for i in x:
for j in y:
price = int(i)+int(j)
answer.append(price)
answer.sort(reverse=True)
del answer[k::]
f_ans = []
for m in answer:
for n in z:
pr... | p03078 |
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
X, Y, Z, K = mapint()
Xs = list(mapint())
Ys = list(mapint())
Zs = list(mapint())
Xs.sort(reverse=True)
Ys.sort(reverse=True)
Zs.sort(reverse=True)
x, y, z = 0, 0,... | import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
X, Y, Z, K = mapint()
As = list(mapint())
Bs = list(mapint())
Cs = list(mapint())
As.sort(reverse=True)
Bs.sort(reverse=True)
Cs.sort(reverse=True)
from heapq impo... | p03078 |
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
res = []
for a in A:
for b in B:
for c in C:
res.append(a + b + c)
res.sort(reverse=True)
for i in range(K):
print((res[i]... |
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
res = []
for a in A:
for b in B:
res.append(a + b)
res.sort(reverse=True)
res2 = []
for v in res[:K]:
for c in C:
res2.appe... | p03078 |
from heapq import heappop, heappush
X, Y, Z, K = list(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)
pq = []
heappush(pq, (-A[0] - B[0] - C[0], 0, 0, 0)... |
X, Y, Z, K = list(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)
res = []
for i in range(X):
for j in range(Y):
for k in range(Z):
... | p03078 |
X,Y,Z,K = list(map(int,input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A = sorted(A, reverse = True)
B = sorted(B, reverse = True)
C = sorted(C, reverse = True)
ans = []
for i in range(min(K,X)):
for j in range(min(K,Y)):
... | X,Y,Z,K = list(map(int,input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A = sorted(A, reverse = True)
B = sorted(B, reverse = True)
C = sorted(C, reverse = True)
ans = []
for i in range(min(K,X)):
for j in range(min(K//(i+1),Y... | p03078 |
X,Y,Z,K = list(map(int,input().split()))
l_a = [int(x) for x in input().split()]
l_b = [int(x) for x in input().split()]
l_c = [int(x) for x in input().split()]
l_a.sort(reverse = True)
l_b.sort(reverse = True)
l_c.sort(reverse = True)
l_d = [a + b for a in l_a for b in l_b]
l_d.sort(reverse = True)
l_d[:3... | X,Y,Z,K = list(map(int,input().split()))
l_a = [int(x) for x in input().split()]
l_b = [int(x) for x in input().split()]
l_c = [int(x) for x in input().split()]
l_a.sort(reverse = True)
l_b.sort(reverse = True)
l_c.sort(reverse = True)
l_d = [a + b for a in l_a for b in l_b]
l_d.sort(reverse = True)
l_d = ... | p03078 |
import sys
from itertools import product
X, Y, Z, K = map(int, input().split())
lst_A = sorted(map(int, input().split()), reverse=True)
lst_B = sorted(map(int, input().split()), reverse=True)
lst_C = sorted(map(int, input().split()), reverse=True)
lst_A_K = lst_A[:K]
lst_B_K = lst_B[:K]
lst_C_K = lst_C[:K]
... | import sys
from itertools import product
X, Y, Z, K = map(int, input().split())
lst_A = list(map(int, input().split()))
lst_B = list(map(int, input().split()))
lst_C = list(map(int, input().split()))
lst_A.sort(reverse=True)
lst_B.sort(reverse=True)
lst_C.sort(reverse=True)
# lst_A_K = lst_A[:K]
# lst_B... | p03078 |
from itertools import product
X, Y, Z, K = list(map(int, input().split()))
lst_A = list(map(int, input().split()))
lst_B = list(map(int, input().split()))
lst_C = list(map(int, input().split()))
lst_A.sort(reverse=True)
lst_B.sort(reverse=True)
lst_C.sort(reverse=True)
lst_A_K = lst_A[:K]
lst_B_K = lst_B... | import sys
from itertools import product
read = sys.stdin.readline
X, Y, Z, K = list(map(int, read().split()))
lst_A = list(map(int, read().split()))
lst_B = list(map(int, read().split()))
lst_C = list(map(int, read().split()))
lst_A.sort(reverse=True)
lst_B.sort(reverse=True)
lst_C.sort(reverse=True)
l... | p03078 |
from itertools import product
X, Y, Z, K = map(int, input().split())
lst_A = list(map(int, input().split()))
lst_B = list(map(int, input().split()))
lst_C = list(map(int, input().split()))
lst_C = lst_C[:K]
lst_AB = [a + b for a, b in product(lst_A, lst_B)]
lst_AB.sort(reverse=True)
K_ = min(3000, X*Y*Z)
... | from itertools import product
X, Y, Z, K = map(int, input().split())
lst_A = list(map(int, input().split()))
lst_B = list(map(int, input().split()))
lst_C = list(map(int, input().split()))
lst_A.sort(reverse=True)
lst_B.sort(reverse=True)
lst_C.sort(reverse=True)
lst_C_K = lst_C[:K]
lst_AB = sorted([... | p03078 |
import itertools
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
AB = [a + b for (a, b) in list(itertools.product(A, B))]
AB.sort(reverse=True)
ans = [ab + c for (ab, c) in list(itertools.product(AB[:mi... | x,y,z,k = list(map(int,input().split()))
lisa = list(map(int,input().split()))
lisb = list(map(int,input().split()))
lisc = list(map(int,input().split()))
lisa.sort(reverse=True)
lisb.sort(reverse=True)
lisc.sort(reverse=True)
an = []
ans = []
for num in lisb:
for nu in lisa:
an.append(num+nu)
a... | p03078 |
x,y,z,k=list(map(int, input().split()))
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))
ab=[]
for i in range(x):
for j in range(y):
ab+=[a[i]+b[j]]
ab.sort(key=lambda x: -x)
c.sort(key=lambda x: -x)
ans=[]
ct=[0]
ansc=[ab[0]+c[0]]
while (len... | x,y,z,k=list(map(int, input().split()))
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))
ab=[]
for i in range(x):
for j in range(y):
ab.append(a[i]+b[j])
ab.sort(key=lambda x: -x)
c.sort(key=lambda x: -x)
ans=[]
ct=[0]
ansc=[ab[0]+c[0]]
while... | p03078 |
X,Y,Z,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
DD = []
A.sort()
B.sort()
C.sort()
for i in A:
for j in B:
DD.append(i+j)
DD.sort()
F = []
for i in DD[min(len(DD)-3010,0):]:
for j in C:
... | X,Y,Z,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
DD = []
A.sort()
B.sort()
C.sort()
for i in A:
for j in B:
DD.append(i+j)
DD.sort()
F = []
for i in DD[max(len(DD)-3010,0):]:
for j in C:
... | p03078 |
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()))
A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)
now = [0, 0, 0]
que = [[A[0] + B[0] + C[0], 0, 0, 0]]
memory = [[A[0] + B[0] + C[0], 0, 0, 0... | 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()))
A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)
now = [0, 0, 0]
que = [[A[0] + B[0] + C[0], 0, 0, 0]]
memory = [[0, 0, 0]]
ans = []
while ... | p03078 |
X, Y, Z, K = list(map(int, input().split()))
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))
import itertools
val_list = []
a_max = min(len(A_list), K)
b_max = min(len(B_list), K)
c_max = min(len(C_list), K)
A_list = sorted(A_li... | X, Y, Z, K = list(map(int, input().split()))
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))
import itertools
val_list = []
A_list = sorted(A_list, reverse=True)
B_list = sorted(B_list, reverse=True)
C_list = sorted(C_list, rev... | p03078 |
x,y,z,k = list(map(int, input().split()))
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
x = 0
y = 0
z = 0
cakes = []
for x, a in enumerate(A):
for y, b in enumerate(B):
... | x,y,z,k = list(map(int, input().split()))
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
x = 0
y = 0
z = 0
cakes = []
for x, a in enumerate(A):
if x+1 > k: break
... | p03078 |
x,y,z,N =(int(i) for i in input().split())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
sa=sorted(a,reverse=True)
sb=sorted(b,reverse=True)
sc=sorted(c,reverse=True)
l=[]#端点情報
n=0
i=0
j=0
k=0
while n<N:
print((sa[i]+sb[j]+sc[k]))
l.app... | #解答を見た後
x,y,z,N =(int(i) for i in input().split())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
sa=sorted(a,reverse=True)
sb=sorted(b,reverse=True)
sc=sorted(c,reverse=True)
answer=[]
for i in range(len(sa)):
for j in range(len(sb)):
... | p03078 |
import heapq
import collections
x,y,z,k = list(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)
heap = []
heapq.heapify(heap)
heapq.heappush(heap,(-(A[0]+B[0]... | from heapq import heappop, heappush, heapify
X, Y, Z, K = list(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)
heap = list()
used = set()
res = list()
heap... | p03078 |
def dfs(count, ans, ll):
if count == 2:
for cc in c:
cccc = ans + cc
if cccc is not None:
ll.append(cccc)
if count == 1:
for bb in b:
bbbb = dfs(count+1, ans+bb, ll)
if bbbb is not None:
ll.append(bbbb)
... | x, y, z, k = list(map(int, input().split()))
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a = list(reversed(sorted(a)))
b = list(reversed(sorted(b)))
c = list(reversed(sorted(c)))
ans = []
for i in range(x):
for j in range(y):
fo... | p03078 |
X, Y, Z, K=list(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)
import heapq
nums=[[-(A[0]+B[0]+C[0]), 0, 0, 0]]
heapq.heapify(nums)
sumi=[[[0]*Z for __ in range(... | X, Y, Z, K=list(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)
import heapq
nums=[[-(A[0]+B[0]+C[0]), 0, 0, 0]]
heapq.heapify(nums)
sumi=[[0, 0, 0]]
for _ in ra... | p03078 |
# coding: utf-8
#解法1 ABのK番まで + CのK番まで
X,Y,Z,K=list(map(int,input().split()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
AB=[]
for i in range(min(K,X)):
for j in range(min(K,Y)):
AB.append(A[i]+B[j])
AB.sort(reverse=True)
C.sort(reverse... | # coding: utf-8
#解法1 ABのK番まで + CのK番まで
X,Y,Z,K=list(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)
ABC=[]
for i in range(X):
for j in range(Y):
for k ... | p03078 |
# coding: utf-8
#解法1 ABのK番まで + CのK番まで
X,Y,Z,K=list(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)
ABC=[]
for i in range(X):
for j in range(Y):
for k ... | # coding: utf-8
#解法2 abc<=Kのみのリスト
X,Y,Z,K=list(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)
ABC=[]
for i in range(X):
for j in range(Y):
for k in r... | p03078 |
import sys
input = sys.stdin.readline
def main():
X, Y, Z, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
ans = []
for a in A:
for b in B:
for c in C:
... | import sys
input = sys.stdin.readline
def main():
X, Y, Z, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
ans = []
for a in A:
for b in B:
ans.append(a + b)
... | p03078 |
x, y, z, k = list(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()
A = A[::-1]
B = B[::-1]
C = C[::-1]
anslist = []
for i in range(len(A)):
if i > k:
break
for j in range(... | x, y, z, k = list(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()
A = A[::-1]
B = B[::-1]
C = C[::-1]
anslist = []
for i in range(len(A)):
if (i + 1) > k:
break
for j in ... | p03078 |
# coding: utf-8
import sys
input = sys.stdin.readline
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
bimi = []
for a in range(X):
for b in range(Y):
bimi.append(A[a] + B[b])
... | # coding: utf-8
import sys
input = sys.stdin.readline
X, Y, Z, K = list(map(int, input().split()))
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
bimi = []
for a in range(X):
... | p03078 |
x,y,z,n = list(map(int, input().split()))
a = sorted(list(map(int, input().split())),reverse = True)
b = sorted(list(map(int, input().split())),reverse = True)
c = sorted(list(map(int, input().split())),reverse = True)
d = []
for i,i1 in enumerate(a):
for j,j1 in enumerate(b):
for k,k1 in enumerate(c):
... | x,y,z,n = list(map(int, input().split()))
a = sorted(list(map(int, input().split())),reverse = True)
b = sorted(list(map(int, input().split())),reverse = True)
c = sorted(list(map(int, input().split())),reverse = True)
d = []
for i,i1 in enumerate(a):
for j,j1 in enumerate(b):
if (i+1)*(j+1) <= n:
f... | p03078 |
def resolve():
X, Y, Z, K = list(map(int, input().split()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
AB = []
for a in A:
for b in B:
AB.append(a+b)
AB = sorted(AB, revers... | def resolve():
X, Y, Z, K = list(map(int, input().split()))
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
ABC = []
for i in range(X):
for j in range(Y)... | p03078 |
import itertools
import heapq
import copy
def inv(l):
return list([x*-1 for x in l])
def solve(A,B,C, K):
A,B,C = inv(A), inv(B), inv(C)
A = sorted(A)
B = sorted(B)
C = sorted(C)
ind = set([(0,0,0)])
h = [(A[0]+ B[0]+ C[0], (0,0,0))]
res = []
for _ in range(K):
... | import itertools
import heapq
import copy
def inv(l):
return list([x*-1 for x in l])
def solve(A,B,C, K):
A,B,C = inv(A), inv(B), inv(C)
A = sorted(A)
B = sorted(B)
C = sorted(C)
ind = set([(0,0,0)])
h = [(A[0]+ B[0]+ C[0], (0,0,0))]
res = []
for _ in range(K):
... | p03078 |
# TODO D - Cake 123
# https://atcoder.jp/contests/abc123/tasks/abc123_d
X, Y, Z, K = list(map(int, input().split()))
A = [int(x) for x in input().split()]
B = [int(y) for y in input().split()]
C = [int(z) for z in input().split()]
AB = sorted([a+b for a in A for b in B], reverse=True)
ABC = sorted([ab + c ... | #abc123d
x,y,z,k=list(map(int,input().split()))
a=sorted(map(int,input().split()),reverse=True)
b=sorted(map(int,input().split()),reverse=True)
c=sorted(map(int,input().split()),reverse=True)
ab=sorted([i+j for i in a for j in b],reverse=True)
res=sorted([ij+l for ij in ab[:k] for l in c],reverse=True)
for... | p03078 |
X, Y, Z, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]
C = [int(_) for _ in input().split()]
A = sorted(A)
B = sorted(B)
C = sorted(C)
maxn = A[0] * B[0] * C[0]
from heapq import *
h = []
heappush(h, (-A[-1] - B[-1] - C[-1], len(A... | X, Y, Z, K = list(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)
# Priority QueueとしてHeapを使う
# Pythonのheapqは小さい順に取り出すので、-1を掛けて負数としてpushしていく
# (-Ai-Bj-Ck,... | p03078 |
import sys
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし
def S(): r... | import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり
X,Y,Z,K = MI()
A,B,C = LI(),LI(),LI()
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
ANS = []
for i in range(X):
if i >= K:
... | p03078 |
X,Y,Z,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
x = []
for a in A:
for b in B:
for c in C:
x.append(a + b + c)
x.sort(reverse=True)
for i in range(K):
print((x[i]))
| x,y,z,k = list(map(int,input().split()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ab = []
for i in range(x):
for j in range(y):
ab.append(a[i] + b[j])
ab.sort(reverse = True)
abc = []
for i in range(min(3000, len(ab))):
for j... | p03078 |
x,y,z,k = list(map(int,input().split()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ab = []
for i in range(x):
for j in range(y):
ab.append(a[i] + b[j])
ab.sort(reverse = True)
abc = []
for i in range(min(k,len(ab))):
for j in ... | x,y,z,k = list(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)
abc = []
for i in range(x):
for j in range(y):
if (i + 1) * (j + 1) > k:
... | p03078 |
x,y,z,k=list(map(int,input().split()))
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
d=[]
ans=[]
for i in a:
for j in b:
d.append(i+j)
for i in c:
for j in d:
ans.append(i+j)
ans.sort(reverse=True)
for i in range(k):
... | x,y,z,k=list(map(int,input().split()))
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
if k>x: a=a[:k]
if k>y: b=b[:k]
if k>z: c=c[:k]
d=[]
ans=[]
for i in a:
for j in b:
... | p03078 |
x,y,z,k=list(map(int,input().split()))
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
if k<x: a=a[:k]
if k<y: b=b[:k]
if k<z: c=c[:k]
d=[]
ans=[]
for i in a:
for j in b:
... | x,y,z,k=list(map(int,input().split()))
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
if k<x: a=a[:k]
if k<y: b=b[:k]
if k<z: c=c[:k]
d=[]
ans=[]
for i in a:
for j in b:
... | p03078 |
def main():
import heapq
x, y, z, k, *abc = map(int, open(0).read().split())
a = abc[:x]
b = abc[x:x + y]
c = abc[x + y:]
s = set()
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
h = [(-(a[0] + b[0] + c[0]), 0, 0, 0)]
heapq.heapify(h)
ans... | def main():
import heapq
x, y, z, k, *abc = list(map(int, open(0).read().split()))
a = sorted(abc[:x], reverse=True)
b = sorted(abc[x:x + y], reverse=True)
c = sorted(abc[x + y:], reverse=True)
s = set()
h = [(-(a[0] + b[0] + c[0]), 0, 0, 0)]
heapq.heapify(h)
num = []
... | p03078 |
import heapq
x, y, z, K = list(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)
n = []
heapq.heapify(n)
heapq.heappush(n, (-(a[0]+b[0] + c[0]), 0,0,0... | import heapq
X, Y, Z, K = list(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)
ans = [(-(a[0]+b[0]+c[0]), 0, 0, 0)]
for i in range(K):
m, j, k, h = heap... | p03078 |
x, y, z, k = list(map(int,input().split()))
a =list(map(int,input().split()))
b =list(map(int,input().split()))
c =list(map(int,input().split()))
ans = []
for aa in a:
for bb in b:
for cc in c:
ans.append(aa+bb+cc)
for ansi in sorted(ans)[::-1][:k]:
print(ansi) | x, y, z, k = list(map(int,input().split()))
a =list(map(int,input().split()))
b =list(map(int,input().split()))
c =list(map(int,input().split()))
ab = []
for aa in a:
for bb in b:
ab.append(aa+bb)
ab = sorted(ab)[::-1][:k]
ans = []
for aabb in ab:
for cc in c:
ans.append(aabb... | p03078 |
x, y, z, k = list(map(int, input().split()))
a_array = sorted([int(x) for x in input().split()], reverse=True)
b_array = sorted([int(x) for x in input().split()], reverse=True)
c_array = sorted([int(x) for x in input().split()], reverse=True)
def solver1():
ab_array = [x + y for x in a_array for y in b_arr... | x, y, z, k = list(map(int, input().split()))
a_array = sorted([int(x) for x in input().split()], reverse=True)
b_array = sorted([int(x) for x in input().split()], reverse=True)
c_array = sorted([int(x) for x in input().split()], reverse=True)
def solver1():
ab_array = sorted([x + y for x in a_array for y i... | p03078 |
# D - Cake 123
import heapq
import itertools
x, y, z, k = list(map(int, input().split()))
A = list(int(a) for a in input().split())
B = list(int(b) for b in input().split())
C = list(int(c) for c in input().split())
hq = []
for i, j in itertools.product(A, B):
heapq.heappush(hq, (i+j)*-1)
AB = [... | # D - Cake 123
import heapq
import itertools
x, y, z, k = list(map(int, input().split()))
A = list(int(a) for a in input().split())
B = list(int(b) for b in input().split())
C = list(int(c) for c in input().split())
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
hq = []
for i in r... | p03078 |
# D - Cake 123
import heapq
import itertools
from collections import defaultdict
x, y, z, k = list(map(int, input().split()))
A = list(int(a) for a in input().split())
B = list(int(b) for b in input().split())
C = list(int(c) for c in input().split())
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(r... | # D - Cake 123
import heapq
import itertools
from collections import defaultdict
x, y, z, k = list(map(int, input().split()))
A = list(int(a) for a in input().split())
B = list(int(b) for b in input().split())
C = list(int(c) for c in input().split())
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(r... | p03078 |
X,Y,Z,K = list(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)
LIS = []
for i in range(X):
for j in range(Y):
for k in range(min((3000//(i+1)*(j+1)),... | X,Y,Z,K = list(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)
LIS = []
for i in range(X):
INTB = 3000//(i+1)
for j in range(min(INTB+1,Y)):
INT... | p03078 |
def int_raw():
return int(eval(input()))
def ss_raw():
return input().split()
def ints_raw():
return list(map(int,ss_raw()))
X,Y,Z,K = ints_raw()
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=T... | def int_raw():
return int(eval(input()))
def ss_raw():
return input().split()
def ints_raw():
return list(map(int,ss_raw()))
X,Y,Z,K = ints_raw()
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=T... | p03078 |
X , Y , Z , K = list(map(int , input().split()))
A = list(map(int , input().split()))
B = list(map(int , input().split()))
C = list(map(int , input().split()))
#入力受け取り
AA = []
BB = []
CC = []
for k in range(min(X, K)):
maxA = max(A)
A.remove(maxA)
AA.append(maxA)
for k in range(min(Y, K)):
m... | X , Y , Z , K = list(map(int , input().split()))
A = list(map(int , input().split()))
B = list(map(int , input().split()))
C = list(map(int , input().split()))
#入力受け取り
AA = []
BB = []
CC = []
for k in range(min(X, K)):
maxA = max(A)
A.remove(maxA)
AA.append(maxA)
for k in range(min(Y, K)):
m... | p03078 |
# PDFで解法が4つも書いてある。これはその最初の解法
x,y,z,k = list(map(int, input().split() ))
aa = list(map(int, input().split() ))
bb = list(map(int, input().split() ))
cc = list(map(int, input().split() ))
aa.sort(reverse = True)
bb.sort(reverse = True)
cc.sort(reverse = True)
# 降順=大きい方から順
ab = []
for i in aa:
for j i... | # PDFで解法が4つも書いてある。これはその最初の解法
x,y,z,k = list(map(int, input().split() ))
aa = list(map(int, input().split() ))
bb = list(map(int, input().split() ))
cc = list(map(int, input().split() ))
aa.sort(reverse = True)
bb.sort(reverse = True)
cc.sort(reverse = True)
# 降順=大きい方から順
ab = [i + j for i in aa for j i... | p03078 |
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readline_s = sys.stdin.readline
readlines = sys.stdin.buffer.readlines
INF = 10 ** 10 + 7
def main():
X, Y, Z, K = list(map(int, readline().split()))
A = sorted(list(map(int, readline().split())), reverse=True)
B =... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readline_s = sys.stdin.readline
readlines = sys.stdin.buffer.readlines
INF = 10 ** 10 + 7
def main():
X, Y, Z, K = list(map(int, readline().split()))
A = sorted(list(map(int, readline().split())), reverse=True)
B =... | p03078 |
def main():
x, y, z, k = list(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
for i in range(x):
for j in range(y):
d[i*y+j] = a[i]+b[j]
d.sort(reverse=True)
c.sort(reverse=True)
c_len = min(k, ... | def main():
x, y, z, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
solve(a, b, c, x, y, z, k)
def solve(a, b, c, x, y, z, k):
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
stack = li... | p03078 |
import heapq
x,y,z,k = list(map(int,input().split()))
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
al = [[[0 for i in range(z)] for j in range(y)] for jj in range(x)]
hq = []
h... | import heapq
x,y,z,k = list(map(int,input().split()))
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
al = []
hq = []
heapq.heappush(hq,(-(a[0]+b[0]+c[0]),0,0,0))
for i in range(... | p03078 |
X,Y,Z,K=list(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()
from heapq import heappush,heappop
ans=[]
data=[(-A[-1]-B[-1]-C[-1],X-1,Y-1,Z-1)]
visited=set()
while len(ans)<K:
now=heappop(data)
if... | X,Y,Z,K=list(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()
from heapq import heappush,heappop
ans=[]
data=[(-A[-1]-B[-1]-C[-1],X-1,Y-1,Z-1)]
visited={(X-1,Y-1,Z-1)}
while len(ans)<K:
now=heappop(dat... | p03078 |
X,Y,Z,K=list(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)
C=C[:K]
from itertools import product
D=sorted([a+b for a,b in product(A,B)],reverse=True)
D=D[:K]
E=sorted([d+c for d,c in product(D,C)],reverse=Tr... | X,Y,Z,K=list(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)
C=C[:K]
from itertools import product
D=sorted([a+b for a,b in product(A,B)],reverse=True)
D=D[:K]
E=sorte... | p03078 |
import sys
read = sys.stdin.readline
def read_ints():
return list(map(int, read().split()))
X, Y, Z, K = read_ints()
A = list(map(int,input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
from itertools import product
AB = [a + b for a, b in product(A, B)]
A... | # 全探索に終了条件を追加することで計算量を削減させるやり方
import sys
read = sys.stdin.readline
def read_ints():
return list(map(int, read().split()))
X, Y, Z, K = read_ints()
A = read_ints()
B = read_ints()
C = read_ints()
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
ABC = []
for a in range(X):
... | p03078 |
# ヒープに要素を追加、一番でかいのを取り出すという操作を最大3000回やるやり方
# これもなかなか早い
# ヒープは追加も要素の取り出しもO(log n)で住むので、
# 計算オーダーはO(K log n)で済む(nはヒープの要素数)らしいが
# not in があるのでO(n K log n)では?
# pythonのヒープは使い方に癖があるのでこの機会に習得しよう
import sys
read = sys.stdin.readline
def read_ints():
return list(map(int, read().split()))
X, Y, Z, K = read_... | # ヒープに要素を追加、一番でかいのを取り出すという操作を最大3000回やるやり方
# これもなかなか早い
# ヒープは追加も要素の取り出しもO(log n)で住むので、
# 計算オーダーはO(K log n)で済む(nはヒープの要素数)らしいが
# not in があるのでO(n K log n)では?
# pythonのヒープは使い方に癖があるのでこの機会に習得しよう
import sys
read = sys.stdin.readline
def read_ints():
return list(map(int, read().split()))
X, Y, Z, K = read_... | p03078 |
# ヒープに要素を追加、一番でかいのを取り出すという操作を最大3000回やるやり方
# これもなかなか早い
# ヒープは追加も要素の取り出しもO(log n)で住むので、
# 計算オーダーはO(K log n)で済む(nはヒープの要素数)らしいが
# not in があるのでO(n K log n)では?
# pythonのヒープは使い方に癖があるのでこの機会に習得しよう
import sys
read = sys.stdin.readline
def read_ints():
return list(map(int, read().split()))
X, Y, Z, K = read_... | # ヒープに要素を追加、一番でかいのを取り出すという操作を最大3000回やるやり方
# これもなかなか早い
# ヒープは追加も要素の取り出しもO(log n)で住むので、
# 計算オーダーはO(K log n)で済む(nはヒープの要素数)らしいが
# not in があるのでO(n K log n)では?
# pythonのヒープは使い方に癖があるのでこの機会に習得しよう
import sys
read = sys.stdin.readline
def read_ints():
return list(map(int, read().split()))
X, Y, Z, K = read_... | p03078 |
x,y,z,k = list(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)
sum_list = []
for a_i in range(x):
for b_i in range(y):
for c_i in range(z):
... | x,y,z,k = list(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)
sum_list = []
for a_i in range(x):
for b_i in range(y):
if a_i*b_i > k:
brea... | p03078 |
import sys
input = sys.stdin.readline
X, Y, Z, K = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
ablst = [m + n for n in b for m in a]
ablst.sort(reverse=True)
c.sort(reverse=True)
abclst = [m + n for n in c... | import sys
input = sys.stdin.readline
X, Y, Z, K = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
ablst = [m + n for n in b for m in a]
ablst.sort(reverse=True)
c.so... | p03078 |
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
sum = []
for x in range(X):
for y in range(Y):
for z in range(Z):
sum.append(A[x] + B[y] + C[z])
sum.sort(reverse=True)
for i... |
X, Y, Z, K = list(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[:K+1]
B = B[:K+1]
C = C[:K+1]
E = []
for a in range(len(A)):
for b in rang... | p03078 |
X, Y, Z, K = list(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 in range(len(A)):
for b in range(len(B)):
E.append(A[a]+B[b])
E.sort(reverse=True)
E = E[:K]
ans = []
for c in range(len(C)... |
X, Y, Z, K = list(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)
sum = []
for x in range(X):
for y in range(Y):
for z in range(Z):
... | p03078 |
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
AB = []
for i in range(X):
for j in range(Y):
AB.append(A[i] + B[j])
AB.sort(reverse=True)
#print(AB)
AB = AB[:K]
ABC = []
for i in range... |
X, Y, Z, K = list(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)
ABC = []
for x in range(X):
for y in range(Y):
for z in range(Z):
... | p03078 |
x = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
a.reverse()
b.sort()
b.reverse()
c.sort()
c.reverse()
l = []
for i in range(x[0]):
for j in range(x[1]):
for k in range(x[2]):
... | x,y,z,k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
d = []
for xx in a:
for yy in b:
d.append(xx+yy)
d.sort()
d.reverse()
e = []
if len(d)>3000:
for i in range(3000):
for zz in c:... | p03078 |
from bisect import bisect_left
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()))
bc = [x + y for y in c for x in b]
bc.sort()
bcl = len(bc)
def bs_l(f, high, low=0):
l, r = low-1, high+1
while r - l ... | 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()))
a.sort(reverse=True)
bc = [x + y for y in c for x in b]
bc.sort(reverse=True)
ans = [x + y for y in a for x in bc[:k]]
ans.sort(reverse=True)
print(*ans[:k], sep="\... | p03078 |
import math
import sys
X,Y,Z,K=list(map(int,input().split()))
x=sorted(list(map(int,input().split())),reverse=True)
y=sorted(list(map(int,input().split())),reverse=True)
z=sorted(list(map(int,input().split())),reverse=True)
"""
if X*Y*Z<=3000:
ans=[]
for i in range(X):
for j in range... | import math
import sys
X,Y,Z,K=list(map(int,input().split()))
x=sorted(list(map(int,input().split())),reverse=True)
y=sorted(list(map(int,input().split())),reverse=True)
z=sorted(list(map(int,input().split())),reverse=True)
"""
if X*Y*Z<=3000:
ans=[]
for i in range(X):
for j in range... | p03078 |
input_out_data = input().split(" ")
cake_sum_point = []
for i in range(4):
input_out_data[i] = int(input_out_data[i])
cake_A = input().split(" ")
cake_B = input().split(" ")
cake_C = input().split(" ")
for k in range(input_out_data[0]):
cake_A[k] = int(cake_A[k])
cake_A.sort(reverse=True)
for k ... | input_out_data = input().split(" ")
cake_sum_point = []
for i in range(4):
input_out_data[i] = int(input_out_data[i])
cake_A = input().split(" ")
cake_B = input().split(" ")
cake_C = input().split(" ")
for k in range(input_out_data[0]):
cake_A[k] = int(cake_A[k])
cake_A.sort(reverse=True)
for k ... | p03078 |
x,y,z,q=list(map(int,input().split()))
a=sorted(map(int,input().split()),reverse=True)
b=sorted(map(int,input().split()),reverse=True)
c=sorted(map(int,input().split()),reverse=True)
def bisect(l,r):
cnt=(l+r)//2
if cnt==l:
return l-1+judge(l)
if judge(cnt):
return bisect(cnt+1,r)
else:
... | x,y,z,q=list(map(int,input().split()))
a=sorted(map(int,input().split()),reverse=True)
b=sorted(map(int,input().split()),reverse=True)
c=sorted(map(int,input().split()),reverse=True)
l=[]
for i in range(x):
for j in range(y):
if i*j>q:
break
for k in range(z):
if i*j*k>q:
break
... | p03078 |
X,Y,Z,K=list(map(int,input().split()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
if X<Y and X<Z:
X,Z=Z,X
A,C=C,A
elif Y<X and Y<Z:
Y,Z=Z,Y
B,C=C,Y
C=sorted(C,reverse=True)
k=min(K,X*Y)
AB=sorted([a+b for a in A for b in B],reverse=True)[:k]
A... | X,Y,Z,K=list(map(int,input().split()))
A=sorted(list(map(int,input().split())),reverse=True)
B=sorted(list(map(int,input().split())),reverse=True)
C=sorted(list(map(int,input().split())),reverse=True)
ans=[]
for i in range(X):
if i+1>K:
break
for j in range(Y):
if (i+1)*(j+1)>K:
break
f... | p03078 |
X, Y, Z, K = list(map(int,input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
sum = 0
ans = []
ans2 = []
for i in range(X):
for j in range(Y):
sum = A[i] + B[j]
ans.append(sum)
ans.sort(reverse=True)
for i in r... | X, Y, Z, K = list(map(int,input().split()))
A = sorted(list(map(int, input().split())),reverse=True)
B = sorted(list(map(int, input().split())),reverse=True)
C = sorted(list(map(int, input().split())),reverse=True)
ans = []
for i in range(X):
for j in range(Y):
if (i+1)*(j+1) > K:
br... | p03078 |
import heapq
X, Y, Z, K = list(map(int, input().split()))
A = sorted([int(i) for i in input().split()], reverse=True)
B = sorted([int(i) for i in input().split()], reverse=True)
C = sorted([int(i) for i in input().split()], reverse=True)
done = [[[True for _ in range(Z+1)] for _ in range(Y+1)] for _ in range(Z+1)]... | import heapq
X, Y, Z, K = list(map(int, input().split()))
A = sorted([int(i) for i in input().split()], reverse=True)
B = sorted([int(i) for i in input().split()], reverse=True)
C = sorted([int(i) for i in input().split()], reverse=True)
# done = [[[True for _ in range(Z+1)] for _ in range(Y+1)] for _ in range(Z+1... | p03078 |
import heapq
X, Y, Z, K = list(map(int, input().split()))
A = sorted([int(i) for i in input().split()], reverse=True)
B = sorted([int(i) for i in input().split()], reverse=True)
C = sorted([int(i) for i in input().split()], reverse=True)
done = [[[False for k in range(Z)] for j in range(Y)] for i in range(X)]
d... | import heapq
X, Y, Z, K = list(map(int, input().split()))
A = sorted([int(i) for i in input().split()], reverse=True)
B = sorted([int(i) for i in input().split()], reverse=True)
C = sorted([int(i) for i in input().split()], reverse=True)
done = {(0, 0, 0)}
hq = [(-(A[0]+B[0]+C[0]), 0, 0, 0)]
heapq.heapify(hq... | p03078 |
import sys
from heapq import heappush,heapify,heappop
input = sys.stdin.readline
x, y, z, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
d = [i + j for i in a for j in b]
d.sort(reverse=1)
c.sort(reverse=1)
q = [(... | # O(klog(k))解法 多分...
import sys
from heapq import heappush,heapify,heappop
input = sys.stdin.readline
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()))
def make_kth(A, B):
n, m = len(A), len(B)
A.sort(re... | p03078 |
# -*- coding: utf-8 -*-
def main():
x, y, z, k = list(map(int, input().split()))
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)
c = sorted(list(map(int, input().split())), reverse=True)
count = min(x * z, k)
ac = lis... | # -*- coding: utf-8 -*-
def main():
x, y, z, k = list(map(int, input().split()))
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)
c = sorted(list(map(int, input().split())), reverse=True)
ac = list()
for ai in a:
... | p03078 |
from heapq import heappop,heappush;import sys;input=sys.stdin.readline
x,y,z,k=list(map(int,input().split()));a,b,c=list(map(int,input().split())),list(map(int,input().split())),list(map(int,input().split()))
q,h,l=[],[],0
for i in a:
for j in b:heappush(q,-(i+j));l+=1
for _ in range(min(l,k)):
t=heappop(q)
... | x,y,z,k=list(map(int,input().split()));a,b,c=list(map(int,input().split())),list(map(int,input().split())),list(map(int,input().split()))
aa=[]
for i in a:
for j in b:aa.append(i+j)
aa.sort(reverse=1)
aa=aa[:k+1]
s=[]
for i in aa:
for j in c:s.append(i+j)
s.sort(reverse=1)
for i in range(k):print((s[i])) | p03078 |
X,Y,Z,K = list(map(int, input().split()))
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
ans = []
for x in range(X):
for y in range(Y):
for z in range(Z):
ans.append(A[x]+B[y]+C[z])
ans.sort(reverse=True)
for k in ... | X,Y,Z,K = list(map(int, input().split()))
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
ans = []
for x in range(X):
for y in range(Y):
ans.append(A[x]+B[y])
ans.sort(reverse=True)
C.sort(reverse=True)
ans2 = []
for k in ra... | p03078 |
x,y,z,k = list(map(int,input().split()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
x_pls_y = []
for i in range(x):
for j in range(y):
x_pls_y.append(a[i]+b[j])
x_pls_y.sort(reverse=True)
xy_pls_z = []
for i in range(m... | x,y,z,K = list(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)
kouho = []
for i in range(x):
for j in range(y):
for k in range(z):
if... | p03078 |
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()))
ab = list()
for a in A:
for b in B:
ab.append(a+b)
ab.sort(reverse=True)
C.sort(reverse=True)
abc = []
for a in ab[:k]:
for b in C:
abc.append(... | import heapq as hq
x,y,z,k = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ab = []
for a in A:
for b in B:
hq.heappush(ab, -a-b)
abc = []
cnt = 0
while cnt < k and ab:
cnt += 1
a = hq.heappop(ab)
... | p03078 |
import heapq
X, Y, Z, K = list(map(int, input().split(" ")))
A = sorted(map(int, input().split(" ")), reverse=True)
B = sorted(map(int, input().split(" ")), reverse=True)
C = sorted(map(int, input().split(" ")), reverse=True)
anslist = []
flag = [[[False for _ in range(K)] for _ in range(K)] for _ in range(... | import heapq
class Delicious (object):
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def total(self):
return(A[self.x] + B[self.y] + C[self.z])
def __lt__(self, other):
return self.total() > other.total()
X, Y, Z, K = list(map(int... | p03078 |
x, y, z, k = list(map(int, input().split()))
a = sorted(list(map(int, input().split())),reverse=True)
b = sorted(list(map(int, input().split())),reverse=True)
c = sorted(list(map(int, input().split())),reverse=True)
useA = [a.pop(0)]
useB = [b.pop(0)]
useC = [c.pop(0)]
if len(a) == 0:
a.append(0)
if len(b) =... | x, y, z, k = list(map(int, input().split()))
a = sorted(list(map(int, input().split())),reverse=True)
b = sorted(list(map(int, input().split())),reverse=True)
c = sorted(list(map(int, input().split())),reverse=True)
def search(a, b):
ret = []
al = len(a)
bl = len(b)
for i in range(min(al, k)):
for ... | p03078 |
x,y,z,k=list(map(int, input().split()))
a=sorted(list(map(int, input().split())),reverse=True)
b=sorted(list(map(int, input().split())),reverse=True)
c=sorted(list(map(int, input().split())),reverse=True)
a=a[:k]
b=b[:k]
sum_ab=[]
for i in a:
for j in b:
sum_ab.append(i+j)
sorted(sum_ab,reve... | x,y,z,k=list(map(int, input().split()))
a=sorted(list(map(int, input().split())),reverse=True)
b=sorted(list(map(int, input().split())),reverse=True)
c=sorted(list(map(int, input().split())),reverse=True)
sum_ab=[]
for i in a:
for j in b:
sum_ab.append(i+j)
sum_ab.sort(reverse=True)
sum_ab= sum... | p03078 |
import sys
from bisect import bisect_left as bi_l, bisect_right as bi_r
x, y, z, k = map(int, sys.stdin.readline().split())
a, b, c = (sorted(map(int, sys.stdin.readline().split())) for _ in range(3))
def count_atleast_k(border):
combs = 0
for i in range(x):
for j in range(y):
... | import sys
from heapq import heappush, heappop
x, y, z, K = map(int, sys.stdin.readline().split())
a, b, c = (sorted(map(int, sys.stdin.readline().split()), reverse=True) for _ in range(3))
def main():
cand = [(-(a[0] + b[0] + c[0]), 0, 0, 0)]
added = set([(0, 0, 0)])
for _ in range(K):
... | p03078 |
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
# まずA, Bで総当たり、上位K個をスタック
tmp = [a+b for a in A for b in B]
tmp.sort(reverse=True)
tmp = tmp[:K]
# 残りのc個に対しても総当たり
ans = [t+c for t in tmp for c in C]
ans.s... |
X, Y, Z, K = list(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, Bで総当たり、上位K個をスタック
tmp = [a+b for a in A for b in B]
tmp.sort(reverse=True)
tmp = tmp... | p03078 |
x,y,z,k = list(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)
li = []
for i in a:
for j in b:
li.append(i + j)
li.sort(reverse = True)
li ... | x,y,z,k = list(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)
li = []
box = []
for i in a:
for j in b:
li.append(i + j)
li.sort(reverse = ... | p03078 |
X, Y, Z, K = list(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)
tot = []
for i in range(X):
for j in range(Y):
for k in range(Z):
if(... | X, Y, Z, K = list(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)
tot = []
for i in range(X):
for j in range(Y):
for k in range(Z):
if(... | p03078 |
import heapq
#Aの中でa番目、Bの中でb番目、Cの中でc番目のものがabc > Kの時、大きい順のK番目以内にabcの組が入ることはない
X, Y, Z, K = list(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)
h = []
c... | 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()))
A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)
bi_comb = []
for i in range(min(X, K)):
for j in range(min(Y, K)):
if (i+1)*(j... | p03078 |
X,Y,Z,K=list(map(int,input().split()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
D=[]
for i in range(X):
for j in range(Y):
D.append(A[X-1-i]+B[Y-1-j])
D.sort()
ans=[]
for i in range(min(K,len(D))):
for j in range(min(K,Z)):
an... | X,Y,Z,K=list(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)
ans=[]
for i in range(X):
for j in range(Y):
for k in range(Z):
if (i+1)*(j+1)*(k+1)... | p03078 |
x,y,z,k=list(map(int,input().split()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
AB=[a+b for a in A for b in B]
AB.sort(reverse=True)
ABC=[ab+c for ab in AB[:min(k,x*y)] for c in C]
ABC.sort(reverse=True)
for i in range(k):
print((ABC[i]))
... | x,y,z,k=list(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)
AB=[a+b for a in A for b in B]
AB.sort(reverse=True)
ABC=[ab+c for ab in AB[:min(k,x*y)] for c in C]
... | p03078 |
x,y,z,k=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=[]
for i in range(x):
for j in range(y):
for n in range(z):
ans.append(a[i]+b[j]+c[n])
ans.sort()
ans=ans[::-1]
cnt=0
while cnt!=k:
print... | x,y,z,k=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ab=[s+t for s in a for t in b]
ab.sort()
ab=ab[-1:-k-1:-1]
abc=[s+t for s in ab for t in c]
abc.sort()
abc=abc[-1:-k-1:-1]
for i in range(len(abc)):
print((abc[i]))
| p03078 |
x,y,z,k=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ab=[s+t for s in a for t in b]
ab.sort()
ab=ab[-1:-k-1:-1]
abc=[s+t for s in ab for t in c]
abc.sort()
abc=abc[-1:-k-1:-1]
for i in range(len(abc)):
print((abc[i]))
| x,y,z,k=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ab=sorted([s+t for s in a for t in b])[-1:-k-1:-1]
abc=sorted([s+t for s in ab for t in c])[-1:-k-1:-1]
for i in range(k):
print((abc[i])) | p03078 |
X , Y , Z , K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
temp_sum = []
for i in range(X):
for j in range(Y):
for k in range(Z):
temp_sum.append(A[i] + B[j] + C[k])
def merge_sort(arr):
if len(arr) <= 1:
... | X , Y , Z , K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = []
A.sort()
A.reverse()
B.sort()
B.reverse()
C.sort()
C.reverse()
for i in range(min(K,len(A))):
if K // (i+1) > 0:
for j in range(min(K // (i+1),... | p03078 |
x, y, z, k = list(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)
ab=[]
for i in a:
for j in b:
ab.append(i+j)
ab.sort(reverse=True)
ab=a... | 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()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
ab = sorted(x+y for x in a for y in b)[:-k-1:-1]
abc = sorted(x+y for x in ab[:k] for y in c)[:-k-... | p03078 |
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()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
ab = sorted(x+y for x in a for y in b)[:-k-1:-1]
c = c[:k]
abc = []
for i in ab:
for j in c... | 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()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
ab = sorted(i+j for i in a for j in b)[:-k-1:-1]
c = c[:k]
abc = sorted(i+j for i in ab for j in ... | p03078 |
import sys
input = sys.stdin.readline
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()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
ab = sorted(i+j for i in a for j in b)[:-k-1:-1]
c = c[:... | import sys
input = sys.stdin.readline
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c=sorted(int(i) for i in input().split())
a.sort(reverse=True)
b.sort(reverse=True)
#c.sort(reverse=True)
ab = sorted(i+j for i in a for j in b)[:-k-1:-1]
... | p03078 |
import sys
input = sys.stdin.readline
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c=sorted(int(i) for i in input().split())[:-k-1:-1]
a.sort(reverse=True)
b.sort(reverse=True)
#c.sort(reverse=True)
ab = sorted(i+j for i in a for j in b)[:... | import sys
input = sys.stdin.readline
x, y, z, k = map(int, input().split())
a = sorted(int(i) for i in input().split())
b = sorted(int(i) for i in input().split())
c = sorted(int(i) for i in input().split())
#a.sort(reverse=True)
#b.sort(reverse=True)
#c.sort(reverse=True)
ab = sorted(i+j for i in a for... | p03078 |
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digi... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digi... | p03078 |
#!/usr/bin/python
import sys
import heapq
R=lambda:list(map(int,sys.stdin.readline().split()))
xa,xb,xc,k=R()
a=sorted(R())
b=sorted(R())
c=sorted(R())
h=set()
q=[[-(a[-1]+b[-1]+c[-1]),xa-1,xb-1,xc-1]]
for _ in range(k):
x,ya,yb,yc=heapq.heappop(q)
print((-x))
if ya>0 and (ya-1,yb,yc) not in h:
h.add... | import sys,heapq
R=lambda:list(map(int,sys.stdin.readline().split()))
x=list(R())
k=x.pop()
a=[sorted(R())for _ in range(3)]
h=set()
q=[[-sum(e[-1] for e in a)]+[e-1 for e in x]]
for _ in range(k):
y=heapq.heappop(q)
x=y.pop(0)
print((-x))
for i in range(3):
ny=list(y)
ny[i]-=1
if y[i] and tuple... | p03078 |
X,Y,Z,K = list(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)
AB = []
for a in A:
for b in B:
AB.append(a+b)
AB.sort(reverse=True)
AB = AB[0:min(3001... | # 通ってるコードをコピペ、ほぼ同じはずなんだけどこれは通る?
x,y,z,k = list(map(int,input().split()))
lisa = list(map(int,input().split()))
lisb = list(map(int,input().split()))
lisc = list(map(int,input().split()))
lisa.sort(reverse=True)
lisb.sort(reverse=True)
lisc.sort(reverse=True)
an = []
ans = []
for num in lisb:
for nu in li... | p03078 |
import sys,bisect
input = sys.stdin.readline
x,y,z,k = list(map(int,input().split()))
a = tuple(map(int,input().split()))
b = tuple(map(int,input().split()))
c = tuple(map(int,input().split()))
ab = []
for e in a:
for w in b:
ab.append(e+w)
ab.sort()
ok = -1
ng = 10**11
while abs(ok-ng... | import sys,bisect
input = sys.stdin.readline
def main():
x,y,z,k = list(map(int,input().split()))
a = tuple(map(int,input().split()))
b = tuple(map(int,input().split()))
c = tuple(map(int,input().split()))
ab = []
for e in a:
for w in b:
ab.append(e+w)
ab... | p03078 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.