input stringlengths 20 127k | target stringlengths 20 119k | problem_id stringlengths 6 6 |
|---|---|---|
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=[]
append=AB.append
for i in range(min(K,X)):
for j in range(min(K,Y)):
append(A[i]+B[j])
AB... | import sys
def main():
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()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
AB=[]
append=AB.ap... | p03078 |
x, y, z, k = list(map(int, input().split()))
k = min(x * y * z, k)
a = sorted(list(map(int, input().split())), reverse=True)[:k]
b = sorted(list(map(int, input().split())), reverse=True)[:k]
c = sorted(list(map(int, input().split())), reverse=True)[:k]
def f(a, b):
results = []
cnt = 0
for i in a:
... | x, y, z, k = list(map(int, input().split()))
k = min(x * y * z, k)
a = sorted(list(map(int, input().split())), reverse=True)[:k]
b = sorted(list(map(int, input().split())), reverse=True)[:k]
c = sorted(list(map(int, input().split())), reverse=True)[:k]
def f(a, b):
return [i + j for i in a for j in b]
ab_res... | 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()))
'''
考え方
各リストをソートして、前からk個分のみの要素にする
'''
'''
import math
cnt_num = math.ceil(pow(k, 1/3))
A = sorted(A,reverse=True)[:cnt_num]
B = sorted(B,reverse=True)[:... | 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)[:k]
B = sorted(B,reverse=True)[:k]
C = sorted(C,reverse=True)[:k]
list_ans = []
for index_a,a in enumerate(A):
for index_b,b in en... | p03078 |
import sys
def p(*a):
s=" ".join(map(str,a))
#print(s)
sys.stderr.write(s+"\n")
X,Y,Z,K = list(map(int, input().split()))
A = sorted(list( map(int, input().split()) ), reverse=True) # 1 2 3 4 5 ...(ソート付き)
B = sorted(list( map(int, input().split()) ), reverse=True) # 1 2 3 4 5 ...(ソート付き)
C = sorted(lis... | import sys
def p(*a):
s=" ".join(map(str,a))
#print(s)
sys.stderr.write(s+"\n")
X,Y,Z,K = list(map(int, input().split()))
A = sorted(list( map(int, input().split()) ), reverse=True) # 1 2 3 4 5 ...(ソート付き)
B = sorted(list( map(int, input().split()) ), reverse=True) # 1 2 3 4 5 ...(ソート付き)
C = sorted(lis... | p03078 |
import sys
input = lambda: sys.stdin.readline().rstrip()
def solve():
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)
... | import sys
input = lambda: sys.stdin.readline().rstrip()
def main():
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=Tru... | 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)
delicious_list = []
for a in A[:min((1000,len(A)))]:
for b in B[:min((1000,len(B)))]:
... | (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)
delicious_list = []
for i in range(len(A)):
for j in range(len(B)):
for k in range(le... | p03078 |
import sys
input = sys.stdin.readline
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()))
a_list.sort(reverse=True)
b_list.sort(reverse=True)
c_list.sort(reverse=True)
tmp_list = [a+b for a i... | import sys
input = sys.stdin.readline
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()))
a_list.sort(reverse=True)
b_list.sort(reverse=True)
c_list.sort(reverse=True)
tmp_list = [a+b for a 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()))
l=[]
for s in a:
for t in b:
l.append(s+t)
l.sort(reverse=True)
n=[]
for s in l[:k+1]:
for t in c:
n.append(s+t)
n.sort(reverse=True)
for i 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)
l=[]
for s in range(x):
for t in range(y):
for u in range(z):
if (s+1)*(t+1)*(u+1)... | p03078 |
from collections import deque, defaultdict
import copy
import bisect
#sys.setrecursionlimit(10 ** 9)
import math
import heapq
import sys
def input():
return sys.stdin.readline().strip()
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split... |
from collections import deque, defaultdict
import copy
import bisect
#sys.setrecursionlimit(10 ** 9)
import math
import heapq
import sys
def input():
return sys.stdin.readline().strip()
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().spl... | p03078 |
from itertools import product
x, y, z, k = list(map(int, input().split()))
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
zs = list(map(int, input().split()))
# xs.sort(reverse=True)
# ys.sort(reverse=True)
# zs.sort(reverse=True)
ans_list = []
for i,a in enumerate(list(product(xs,ys... | from itertools import product
x, y, z, k = list(map(int, input().split()))
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
zs = list(map(int, input().split()))
xy_list = []
for i,xy in enumerate(list(product(xs,ys))):
xy_list.append(sum(xy))
xy_list.sort(reverse=True)
xy_list ... | 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 = list()
for i in A:
for j in B:
AB.append(i+j)
AB.sort(reverse=True)
ABC = list()
for i in AB[:K]:
for j in C:
ABC.append... | 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 = list()
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 = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = [p+q+r for p in a for q in b for r in c]
ans.sort(reverse=True)
for i in range(k):
print((ans[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()))
e = [i + j for i in a for j in b]
e.sort(reverse=True)
e = e[:k]
ans = [i + j for i in e for j in c]
ans.sort(reverse=True)
ans = ans[:k]
for i 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()))
e = [i + j for i in a for j in b]
e.sort(reverse=True)
e = e[:k]
ans = [i + j for i in e for j in c]
ans.sort(reverse=True)
for i in range(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()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
e = [i + j for i in a[:k] for j in b[:k]]
e.sort(reverse=True)
e = e[:k]
ans = [i + j for i... | 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()))
'''
必ず3つからそれぞれ1つずつ取らないといけないので、a,bの組み合わせの大きい順
とa,b,cの組の大きい順で見たときの(a,b)の順は一致している
a,bの組み合わせのうち上からk番目以降は考える必要がない
'''
ab = []
for i in range(x):
for j in range(y):
... | 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 = []
for i in range(x):
for j in range(y):
ab.append(a[i] + b[j])
ab.sort(reverse=True)
ab = ab[:k]
rec = []
for i in range(min(x*y, k)):
for j in... | p03078 |
X,Y,Z,K = (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()]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
ans = []
for a in A:
for b in B:
for c in C:
ans.append(a+b+c)
ans.sor... | X,Y,Z,K = (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()]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
ans = []
b=0
c=0
for a in range(len(A)):
for b in range(len(B)):
for c in r... | p03078 |
x,y,z,k=list(map(int,input().split()))
list_a=list(map(int,input().split()))
list_b=list(map(int,input().split()))
list_c=list(map(int,input().split()))
list_a.sort(reverse=True)
list_b.sort(reverse=True)
list_c.sort(reverse=True)
dict_p={}
dict_p[(0,0,0)]=list_a[0]+list_b[0]+list_c[0]
pop_list=[]
for i in ra... | x,y,z,k=list(map(int,input().split()))
list_a=list(map(int,input().split()))
list_b=list(map(int,input().split()))
list_c=list(map(int,input().split()))
list_a.sort(reverse=True)
list_b.sort(reverse=True)
list_c.sort(reverse=True)
dict_p={}
dict_p[(0,0,0)]=list_a[0]+list_b[0]+list_c[0]
pop_list=[]
for i in ra... | p03078 |
from itertools import product
X,Y,Z,K = 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)
L_a = []
L_b = []
L_c = []
for i in range(X) :
L_a.append(A[0] - A[i])... | X,Y,Z,K = map(int,input().split())
A = sorted(list(map(int,input().split())))[::-1]
B = sorted(list(map(int,input().split())))[::-1]
C = sorted(list(map(int,input().split())))[::-1]
L = []
for i in range(X) :
for j in range(Y) :
L.append(A[i]+B[j])
L = sorted(L)[::-1][:K]
L2 = []
for i in rang... | p03078 |
from heapq import heappush, heappushpop
def main():
x, y, z, k = list(map(int, input().split()))
aa = sorted(map(int, input().split()), reverse=True)
bb = sorted(map(int, input().split()), reverse=True)
cc = sorted(map(int, input().split()), reverse=True)
heap = []
for a in aa:
... | from heapq import heappop, heappush
def main():
x, y, z, k = list(map(int, input().split()))
aa = sorted(map(int, input().split()))
bb = sorted(map(int, input().split()))
cc = sorted(map(int, input().split()))
v = aa[-1] + bb[-1] + cc[-1]
t = (len(aa) - 1, len(bb) - 1, len(cc) - 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)
ans = []
for i in range(X):
for j in range(Y):
for k in range(Z):
if (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)
ans = []
for i in range(X):
for j in range(Y):
for k in range(Z):
if (i+... | p03078 |
x, y, z, k = [int(i) for i in input().split()]
p = [int(a) for a in input().split()]
q = [int(b) for b in input().split()]
r = [int(c) for c in input().split()]
p = sorted(p, reverse=True)
q = sorted(q, reverse=True)
r = sorted(r, reverse=True)
pqr = []
for a in range(len(p)):
if a+1 > k:
continue... | X, Y, Z, K = [int(x) for x in input().split()]
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]
A = sorted(A, reverse=True)
B = sorted(B, reverse=True)
C = sorted(C, reverse=True)
ABC = []
for a in range(len(A)):
if a+1 > K:
break
... | p03078 |
X, Y, Z, K = [int(x) for x in input().split()]
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]
A = sorted(A, reverse=True)
B = sorted(B, reverse=True)
C = sorted(C, reverse=True)
ABC = []
for a in range(len(A)):
if a+1 > K:
break
... | X, Y, Z, K = [int(x) for x in input().split()]
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]
A = sorted(A, reverse=True)
B = sorted(B, reverse=True)
C = sorted(C, reverse=True)
ABC = []
for a in range(len(A)):
if a+1 > K:
break
... | p03078 |
X, Y, Z, K = [int(x) for x in input().split()]
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]
A = sorted(A, reverse=True)
B = sorted(B, reverse=True)
C = sorted(C, reverse=True)
ABC = []
for a in range(len(A)):
if a+1 > K:
break
... | X, Y, Z, K = [int(x) for x in input().split()]
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]
A = sorted(A, reverse=True)
B = sorted(B, reverse=True)
C = sorted(C, reverse=True)
ABC = []
for a in range(len(A)):
if a+1 > K:
break
... | p03078 |
X, Y, Z, K = [int(x) for x in input().split()]
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]
A = sorted(A, reverse=True)
B = sorted(B, reverse=True)
C = sorted(C, reverse=True)
ABC = []
for a in range(len(A)):
for b in range(len(B)):
... | X, Y, Z, K = [int(x) for x in input().split()]
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]
A = sorted(A, reverse=True)
B = sorted(B, reverse=True)
C = sorted(C, reverse=True)
ABC = []
for a in range(len(A)):
for b in range(len(B)):
... | p03078 |
import sys
import math
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
x,y,z,p = 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()
"""
if x*y*z <= 3*10**6:
abc = []
for i in ... | import sys
import math
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
x,y,z,p = 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()
"""
if x*y*z <= 3*10**6:
abc = []
for i in ... | p03078 |
def main():
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()))
AB = [a+b for a in A for b in B]
res = [c+ab for c in C for ab in AB]
res.sort(reverse = True)
... | def main():
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()))
A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)
AB = [a+b for a in A fo... | p03078 |
def main():
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()))
A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)
res = []
for i ... | def main():
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()))
A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)
res = []
for i ... | p03078 |
x,y,z,K = list(map(int,input().split()))
ans = 0
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):
... | x,y,z,K = list(map(int,input().split()))
ans = 0
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(min(K//(i+1),y)):
for k in range(mi... | 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()))
taste_list = []
for i in range(X):
for j in range(Y):
for k in range(Z):
taste_list.append(A_list[i]+B_list[j]+C_list[k])
taste_list... | 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:
AB.append(a+b)
AB.sort(reverse=True)
AB = AB[:K]
ABC = []
for ab in AB:
for c in C:
ABC.append... | p03078 |
from collections import defaultdict
inpl = lambda: list(map(int,input().split()))
X, Y, Z, K = inpl()
A = [ sorted(inpl(), key=lambda x: -x) for _ in range(3) ]
N = [X, Y, Z]
mem = defaultdict(int)
ans = sum([A[i][0] for i in range(3)])
mem[(0,0,0)] = 1
cand = [(ans,0,0,0)]
for i in range(K):
cand.s... | from collections import defaultdict
import heapq
inpl = lambda: list(map(int,input().split()))
X, Y, Z, K = inpl()
A = [ sorted(inpl(), reverse=True) for _ in range(3) ]
N = [X, Y, Z]
mem = defaultdict(int)
score = sum([A[i][0] for i in range(3)])
mem[(0,0,0)] = 1
candidates = []
heapq.heappush(candidates... | p03078 |
import itertools
x, y, z, k = list(map(int, input().split()))
al = list(map(int,input().split()))
bl = list(map(int,input().split()))
cl = list(map(int,input().split()))
sum_list = []
for i in list(itertools.product(al, bl, cl)):
sum_list.append(sum(i))
sum_list.sort(reverse=True)
for i in sum_list[:k]:
p... | import itertools
x, y, z, k = list(map(int, input().split()))
al = list(map(int,input().split()))
bl = list(map(int,input().split()))
cl = list(map(int,input().split()))
sum_list = [sum(i) for i in itertools.product(al, bl, cl)]
sum_list.sort(reverse=True)
for i in sum_list[:k]:
print(i) | p03078 |
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(list(ax+bx for ax in a for bx in b), reverse=True)[:k[3]]
abc = sorted(list(aby+cy for aby in ab for cy in c), reverse=True)[:k[3]]
for i in abc: print(i)
| 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)[:k[3]]
B = sorted(b, reverse=True)[:k[3]]
C = sorted(c, reverse=True)[:k[3]]
ab = sorted(list(ax+bx for ax in A for bx in B), reverse=True)[:... | 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(key=lambda x:-x)
b.sort(key=lambda x:-x)
c.sort(key=lambda x:-x)
sumAB=[0 for _ in range(x*y)]
index=0
imax=min(k,x)
jmax=min(k,y)
for i in range(imax):
for ... |
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(key=lambda x:-x)
b.sort(key=lambda x:-x)
c.sort(key=lambda x:-x)
beauty=[]
index=0
for i in range(x):
for j in range(y):
for l in range(z):
... | p03078 |
X,Y,Z,K = list(map(int, input().split()))
A = sorted(list(map(int, input().split())))[:K]
B = sorted(list(map(int, input().split())))[:K]
C = sorted(list(map(int, input().split())))[:K]
ab = sorted(list(a+b for a in A for b in B), reverse = True)[:K]
abc = sorted(list(ab+c for ab in ab for c in C), reverse = T... | X,Y,Z,K = list(map(int, input().split()))
A = sorted(list(map(int, input().split()))[:K])
B = sorted(list(map(int, input().split()))[:K])
C = sorted(list(map(int, input().split()))[:K])
ab = sorted(list(a+b for a in A for b in B), reverse = True)[:K]
abc = sorted(list(ab+c for ab in ab for c in C), reverse = T... | p03078 |
def main():
x,y,z,k = [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()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
ans = []
for i in range(x):
... |
x,y,z,k = [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()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
ans=[]
for i in range(x):
if i > k:
break
for j in range(y):
... | p03078 |
X,Y,Z,K=[int(s) for s in input().split()]
xls=sorted([int(s) for s in input().split()],reverse=True)
yls=sorted([int(s) for s in input().split()],reverse=True)
zls=sorted([int(s) for s in input().split()],reverse=True)
xyls=[]
for x in xls[:K]:
for y in yls[:K]:
xyls.append(x+y)
xyls=sorted(xyls,reverse=T... | X,Y,Z,K=[int(s) for s in input().split()]
xls=sorted([int(s) for s in input().split()],reverse=True)
yls=sorted([int(s) for s in input().split()],reverse=True)
zls=sorted([int(s) for s in input().split()],reverse=True)
cake=[]
for a in range(X):
for b in range(Y):
ab=(a+1)*(b+1)
for c in range(Z):
... | p03078 |
import sys
from bisect import bisect_left,bisect_right,insort
input = sys.stdin.readline
def main():
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())))
l,r=a[0]+b[0]+c[0],a[-1]+b[... | 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)
AB = AB[:k]
ABC = [ab + c for ab in AB for c in C]
ABC.sort(reverse=True)
ABC = ABC[:k]
pri... | p03078 |
import itertools
X, Y, Z, K = (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()]
A = sorted(A)[::-1][:K]
B = sorted(B)[::-1][:K]
C = sorted(C)[::-1][:K]
T = [A, B]
score = []
for cand in itertools.product... | import itertools
X, Y, Z, K = (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()]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
D = [a+b for a,b in itertools.product(A[:K], B[:K])]
D.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()))
L = []
for i in range(len(A)):
for j in range(len(B)):
L.append(A[i] + B[j])
L.sort(reverse=True)
ans_list = [0] * (10000000)
for i 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()
b.sort()
c.sort()
bc = [0] * (y * z)
q = 0
for i in range(y):
for j in range(z):
bc[q] = b[i] + c[j]
q += 1
bc.sort(... | p03078 |
import heapq
X,Y,Z,K=[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(" ")]
AB=[]
for a in A:
for b in B:
AB.append(a+b)
AB=heapq.nlargest(K,AB)
ABC=[]
for ab in AB:
for c in C:
AB... | X,Y,Z,K=[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(" ")]
AB=[]
A=sorted(A,reverse=True)[:K:]
B=sorted(B,reverse=True)[:K:]
C=sorted(C,reverse=True)[:K:]
for a in A:
for b in B:
AB.append(... | 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()))
l = []
for i in a:
for j in b:
l.append(i + j)
c.sort(reverse=True)
l.sort(reverse=True)
l2 = []
for i in c:
for j in l:
l2.append(i + j... | 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()))
l = []
for i in a:
for j in b:
l.append(i + j)
c.sort(reverse=True)
l.sort(reverse=True)
l = l[:k]
l2 = []
for i in c:
for j in l:
l2.a... | p03078 |
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()]
A.sort()
B.sort()
C.sort()
A.reverse()
B.reverse()
C.reverse()
li=[]
inf = 10**11
for i in range(X):
for j in range(Y):
if((i+1)*(j+1)>K... | 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()]
A.sort()
B.sort()
C.sort()
A.reverse()
B.reverse()
C.reverse()
li=[]
for i in range(X):
for j in range(Y):
if((i+1)*(j+1)>K): break
... | p03078 |
from heapq import heapify,heappop,heappush
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)
que=[[-(A[0]+B[0]+C[0]),0,0,0]];heapify(que)
Count=[[[0]*(Z+1) for i in range(Y+1)] fo... | from heapq import heapify,heappop,heappush
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)
que=[[-(A[0]+B[0]+C[0]),0,0,0]];heapify(que)
s=set()
for i in range(K):
p=heap... | p03078 |
from itertools import groupby
from operator import itemgetter
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()]
# key, group
ga0 = [{'val':key, 'cnt':len(list(group))} for key, group in groupby(a)]
ga =... | import heapq
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()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
# heap
h = []
g = set()
heapq.heappush(h, (-(a[0]+b[0]+c[0]),0,0,0))
for i... | p03078 |
import sys
import heapq
input = sys.stdin.readline
def main():
X, Y, Z, K = list(map(int, input().split()))
A = list([-int(x) for x in input().split()])
B = list([-int(x) for x in input().split()])
C = list([-int(x) for x in input().split()])
A.sort()
B.sort()
C.sort()
... | import sys
import heapq
input = sys.stdin.readline
def main():
X, Y, Z, K = list(map(int, input().split()))
A = list([-int(x) for x in input().split()])
B = list([-int(x) for x in input().split()])
C = list([-int(x) for x in input().split()])
A.sort()
B.sort()
C.sort()
... | p03078 |
import sys
readline = sys.stdin.readline
X,Y,Z,K = list(map(int,readline().split()))
A = sorted(list(map(int,readline().split())),reverse = True)
B = sorted(list(map(int,readline().split())),reverse = True)
C = sorted(list(map(int,readline().split())),reverse = True)
# AとBを組み合わせたケーキの上位K位を作る
AB = []
for a ... | import sys
readline = sys.stdin.readline
X,Y,Z,K = map(int,readline().split())
A = sorted(list(map(int,readline().split())),reverse = True)
B = sorted(list(map(int,readline().split())),reverse = True)
C = sorted(list(map(int,readline().split())),reverse = True)
ans = []
for a in range(len(A)):
for b in ... | p03078 |
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=[]
for a in A:
for b in B:
AB.append(a+b)
ABC=[]
for ab in sorted(AB, reverse=True)[:K]:
for c in C:
ABC.append... | 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:
AB.append(a+b)
ABC=[]
for ab in sorted(AB, reverse=True)[:K]:
for c in C:
ABC.append(ab+c)
for abc in sorted(ABC, reverse=True)[:K]... | p03078 |
import itertools
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()]
list_ = [a+b+c for (a,b,c) in itertools.product(A, B, C)]
list_.sort(reverse=True)
for N in list_[:K]:
print(N) | import itertools
X, Y, Z, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
A.sort(reverse=True)
B = [int(x) for x in input().split()]
B.sort(reverse=True)
C = [int(x) for x in input().split()]
C.sort(reverse=True)
list_ = [b+c for (b,c) in itertools.product(B, C)]
list_.sort(rev... | p03078 |
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(X, Y, Z, K, As, Bs, Cs):
ABs = []
for A in As:
for B in Bs:
ABs.append(A + B)
ABs.sort(reverse=True)
ABCs = []
... | # 解説を参考に作成
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(X, Y, Z, K, As, Bs, Cs):
ABs = []
for A in As:
for B in Bs:
ABs.append(A + B)
ABs.sort(reverse=True)
... | p03078 |
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
input = sys.stdin.readline
# bisect_left(lists, 3)
# bisect_right(lists, 3)
def main():
X, Y, Z, K = list(map(int, input().split(" ")))
As = []
Bs = []
Cs = []
As = input().split()
As = ... | # -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
input = sys.stdin.readline
# bisect_left(lists, 3)
# bisect_right(lists, 3)
def main():
X, Y, Z, K = list(map(int, input().split(" ")))
As = []
Bs = []
Cs = []
As = input().split()
As = ... | 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 = []
E = []
for i in range(x):
for j in range(y):
D.append(A[i]+B[j])
for i in range(z):
for j in range(len(D)):
E.append(C[i]+D[j])
print(("\n".... | x, y, z, k = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list((list(map(int,input().split()))))
D = []
E = []
for i in range(x):
for j in range(y):
D.append(A[i]+B[j])
D.sort()
for i in range(z):
for j in range(min(len(D),k)):
E.append... | p03078 |
x, y, z, k = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list((list(map(int,input().split()))))
D = []
E = []
for i in range(x):
for j in range(y):
D.append(A[i]+B[j])
D = sorted(D,reverse=True)[:k]
for j in range(len(D)):
for i in range(z)... | x, y, z, k = [int(n) for n in input().split()]
va = sorted([int(n) for n in input().split()], reverse=True)
vb = sorted([int(n) for n in input().split()], reverse=True)
xy = min(x*y, k)
vab = (sorted([a + b for a in va for b in vb], reverse=True))[:xy]
vc = sorted([int(n) for n in input().split()], reverse=True)
... | p03078 |
def MergeSort(arr):
if len(arr) <= 1:
return arr
mid = len(arr) // 2
left = arr[:mid]
right = arr[mid:]
left = MergeSort(left)
right = MergeSort(right)
return MergeArray(left, right)
def MergeArray(left, right):
merged = []
li, ri = 0, 0
while li < len(left)... | def MergeSort(arr):
if len(arr) <= 1:
return arr
mid = len(arr) // 2
left = arr[:mid]
right = arr[mid:]
left = MergeSort(left)
right = MergeSort(right)
return MergeArray(left, right)
def MergeArray(left, right):
merged = []
li, ri = 0, 0
while li < len(left)... | p03078 |
def get_input():
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()]
return X, Y, Z, K, A, B, C
def solve():
X, Y, Z, K, A, B, C = get_input()
A = MergeSort(A)[:K]
B = ... | def get_input():
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()]
return X, Y, Z, K, A, B, C
def AddToQueue(_ele, _queue, _ijk_set, K):
if len(_queue) == 0:
_queue.ap... | p03078 |
def get_input():
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()]
return X, Y, Z, K, A, B, C
def AddToQueue(_ele, _queue, _ijk_set, K):
if len(_queue) == 0:
_queue.ap... | def get_input():
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()]
return X, Y, Z, K, A, B, C
def solve2():
X, Y, Z, K, A, B, C = get_input()
A.sort(reverse = True)
B... | p03078 |
k = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
z = [int(i) for i in input().split()]
x.sort()
y.sort()
z.sort()
e = []
for i in x:
for j in y:
e.append(i+j)
e.sort()
f = []
for i in e:
for j in z:
f.append(i+j)
... | 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)
SUM=[]
for i in range(X):
for j in range(Y):
for k in range(Z):
if (i+1)*(j+1)*(k+1)<=K... | p03078 |
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()))
l1=sorted([i+j for i in a for j in b],reverse=True)[:k]
l2=sorted([i+j for i in l1 for j in c],reverse=True)[:k]
for i in l2:
print(i... | 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()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
l1=sorted([i+j for i in a for j in b],reverse=True)[:k]
l2=sorted([i+j fo... | p03078 |
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 = []
for i in range(X):
for j in range(Y):
AB.append(A[i] + B[j])
AB.sort(reverse=True)
... | 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)
ABC = []
for a in range(X):
for b in range(Y):
if (a + 1) * (b + 1) > K:
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()))
Al = sorted(A,reverse=True)[:K]
Bl = sorted(B,reverse=True)[:K]
Cl = sorted(C,reverse=True)[:K]
result = []
for a in Al:
for b in Bl:
for c 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()))
Al = sorted(A,reverse=True)[:K]
Bl = sorted(B,reverse=True)[:K]
Cl = sorted(C,reverse=True)[:K]
ABl = []
for a in Al:
for b in Bl:
ABl.append... | p03078 |
X,Y,Z,K = list(map(int,input().split()))
list_a = list(map(int,input().split()))
list_b = list(map(int,input().split()))
list_c = list(map(int,input().split()))
list_a.sort(reverse=True)
list_b.sort(reverse=True)
list_c.sort(reverse=True)
list = []
for la in list_a:
for lb in list_b:
list.ap... | X,Y,Z,K = list(map(int,input().split()))
list_a = list(map(int,input().split()))
list_b = list(map(int,input().split()))
list_c = list(map(int,input().split()))
list_a.sort(reverse=True)
list_b.sort(reverse=True)
list_c.sort(reverse=True)
sum_ = []
for a in range(X):
for b in range(Y):
for c... | p03078 |
import itertools
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 = []
for a, b in itertools.product(A, B):
d = a + b
D.append(d)
D.sort(reverse = True)
E = []
for c, d in itertools.pro... | 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)
D = []
for i in range(X):
for j in range(Y):
if (i + 1) * (j + 1) > ... | p03078 |
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)
ab=[a[i]+b[j] for j in range(y) for i in range(x)]
ab.sort(reverse=True)
ab=ab[:k]
l=len(ab)
abc=[ab[i... | 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()
b.sort()
c.sort()
ab=[a[i]+b[j] for j in range(y) for i in range(x)]
ab.sort(reverse=True)
ab=ab[:k]
l=len(ab)
abc=[ab[i]+c[j] for j in range(z) for i in... | p03078 |
#AC済み
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()
b.sort()
c.sort()
ab=[-a[i]-b[j] for j in range(y) for i in range(x)]
ab.sort()
ab=ab[:k]
l=len(ab)
abc=[ab[i]-c[j] for j in range(z) for i in ran... | #AC済み
x,y,z,k=list(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()
b.sort()
c.sort()
ab=[a[i]+b[j] for j in range(y) for i in range(x)]
ab.sort(reverse=True)
ab=ab[:k]
l=len(ab)
abc=[ab[i]+... | p03078 |
#AC済み
x,y,z,k=list(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()])
ab=[a[i]+b[j] for j in range(y) for i in range(x)]
ab.sort(reverse=True)
ab=ab[:k]
l=len(ab)
abc=[ab[i]+c[j] for j in range(z) for i i... | #AC済み
x,y,z,k=list(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()])
ab=sorted([a[i]+b[j] for j in range(y) for i in range(x)],reverse=True)
ab=ab[:k]
l=len(ab)
abc=sorted([ab[i]+c[j] for j in range(z) fo... | p03078 |
import itertools
X, Y, Z, K = list(map(int, input().rstrip().split()))
A = list(map(int, input().rstrip().split()))
B = list(map(int, input().rstrip().split()))
C = list(map(int, input().rstrip().split()))
A.sort()
B.sort()
C.sort()
combinations = list(itertools.product(A, B, C))
total = []
for combination in... | import itertools
X, Y, Z, K = list(map(int, input().rstrip().split()))
A = list(map(int, input().rstrip().split()))
B = list(map(int, input().rstrip().split()))
C = list(map(int, input().rstrip().split()))
A.sort()
B.sort()
C.sort()
if X*Y*Z != K:
if X >= 200:
A = A[:200]
if Y >= 200:
... | p03078 |
from heapq import heappush, heappop
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()))
used = [[[False] * (z + 1) for _ in range(y + 1)] for _ in range(x + 1)]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort... | # pypyでギリ。
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
x, y, z, k = map(int, readline().split())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))
C = list(map(int, readline().split()))
goukei = []
for a in... | 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)
tmp=[]
for i in range(x):
for j in range(y):
tmp.append(a[i]+b[j])
tmp.sort(reverse=True)
ans... | 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):
if (i+1)*(j+1)>K:
break
for k ... | p03078 |
import math
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)
l=[]
stat=int(math.sqrt(10**7//X))
for i in range(X):
for j in range(min(stat,Y)):
... | import math
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)
l=[]
#まずX+Yを求め、上から順にソート
#10^6相当の計算
for i in range(X):
for j in range(Y):
l.append(... | p03078 |
import heapq
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()))
AA = list([x*(-1) for x in A])
BB = list([x*(-1) for x in B])
CC = list([x*(-1) for x in C])
an... | from heapq import heappush, heapify, heappop
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()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
... | 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()
AB.reverse()
ABC = [ab + c for ab in AB for c in C]
ABC.sort()
ABC.reverse()
for k in range(K):
print((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()))
AB = [a + b for a in A for b in B]
AB.sort()
AB.reverse()
AB = AB[:min(K, X*Y)]
ABC = [ab + c for ab in AB for c in C]
ABC.sort()
ABC.reverse()
for k in ran... | p03078 |
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 = [A[x]+B[y] for x in range(X) for y in range(Y)]
AB.sort(reverse=True)
AB = AB[:K]
XY = len(AB)
ABC =... | 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 = [A[x] + B[y] for y in range(Y) for x in range(X)]
AB.sort(reverse=True)
AB = AB[:K]
ABC = [AB[x] + C[... | p03078 |
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 = [A[x] + B[y] for y in range(Y) for x in range(X)]
AB.sort(reverse=True)
AB = AB[:K]
XY = len(AB)
ABC... | 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 = [a+b for a in A for b in B]
AB.sort(reverse=True)
AB = AB[:K]
XY = len(AB)
ABC = [ab+c for c in C fo... | p03078 |
# -*- coding: utf-8 -*-
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()))
v = []
d = [e1+e2 for e1 in a for e2 in b]
d.sort(reverse=True)
d = d[:k]
e = [e1+e2 for e1 in d for e2 in c]
e.sort(reverse=True... | # -*- coding: utf-8 -*-
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)
d = [e1+e2 for e1 in a for e2 in b]
d.sort(reverse=True)
d = d[:k]
... | p03078 |
import heapq
class UnionFind():
def __init__(self,n):
self.n=n
self.root=[-1]*(n+1)
self.rank=[0]*(n+1)
def FindRoot(self,x):
if self.root[x]<0:
return x
else:
self.root[x]=self.FindRoot(self.root[x])
return self.root[x]
def Unite(self,x,y):
x=self.FindRoot... | import heapq
class UnionFind():
def __init__(self,n):
self.n=n
self.root=[-1]*(n+1)
self.rank=[0]*(n+1)
def FindRoot(self,x):
if self.root[x]<0:
return x
else:
self.root[x]=self.FindRoot(self.root[x])
return self.root[x]
def Unite(self,x,y):
x=self.FindRoot... | p03440 |
from collections import*
from heapq import*
(n,m),a,*q=[[*map(int,o.split())]for o in open(0)]
t=[-1]*n
def r(x):
while t[x]>=0:x=t[x]
return x
def u(x,y):
x,y=r(x),r(y)
if x!=y:
if t[x]>t[y]:x,y=y,x
t[x]+=t[y];t[y]=x
d=defaultdict(list)
for x,y in q:u(x,y)
i=0
for v in a:d[r(i)]+=v,;i+=1
if len... | from collections import*
from heapq import*
(n,m),a,*q=[[*map(int,o.split())]for o in open(0)]
t=[-1]*n
def r(x):
while t[x]>=0:x=t[x]
return x
def u(x,y):
x,y=r(x),r(y)
if x!=y:
if t[x]>t[y]:x,y=y,x
t[x]+=t[y];t[y]=x
d=defaultdict(list)
for x,y in q:u(x,y)
i=c=0;b=[];k=(n+~m)*2
for v in a:d[r(i)... | p03440 |
import sys
input = sys.stdin.buffer.readline
from collections import defaultdict
import heapq
def main():
N,M = list(map(int,input().split()))
a = list(map(int,input().split()))
d = defaultdict(list)
I = [i for i in range(N)]
rank = [1 for _ in range(N)]
def root(a):
... | class UnionFind:
def __init__(self, n):
self.par = [i for i in range(n)]
self.rank = [0]*n
def find(self, x):
if self.par[x]==x:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
def unit(self, x, y):
x = self.find(x)
y = self.find(y)
... | p03440 |
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import bisect
def read():
return int(eval(input()))
def reads():
return [int(x) for x in input().split()]
def main():
N, M = reads()
A = reads()
d = ... | from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import bisect
def read():
return int(eval(input()))
def reads():
return [int(x) for x in input().split()]
def main():
N, M = reads()
A = reads()
if M =... | p03440 |
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from heapq import heappop,heappush
n,m = list(map(int,readline().split()))
a = list(map(int,readline().split()))
xy = list(map(int,read().split()))
if(n-m==1):
print((0))
exit()
p... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from heapq import heappop,heappush
n,m = list(map(int,readline().split()))
a = list(map(int,readline().split()))
xy = list(map(int,read().split()))
if(n-m==1):
print((0))
exit()
p... | p03440 |
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
... | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
... | p03440 |
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
... | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
... | p03440 |
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools
import queue
from collections import deque
parent_data = []
def union(ind):
global parent_data
... | from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools
import queue
from collections import deque
parent_data = []
def union(ind):
global parent_data
... | p03440 |
from collections import deque
from collections import defaultdict
import heapq
N,M=list(map(int, input().split()))
cost=list(map(int, input().split()))
if M==N-1:
print(0)
quit()
nl=[ [] for i in range(N) ]
for i in range(M):
x,y=list(map(int,input().split()))
nl[x].append(y)
nl[y].append(x)
... | from collections import deque
from collections import defaultdict
import heapq
N,M=list(map(int, input().split()))
cost=list(map(int, input().split()))
par=[i for i in range(N)]
def root(x):
if par[x]==x:
return x
else:
r=root(par[x])
par[x]=r
return r
def unite(x,y):
x=root(x)
y=root... | p03440 |
def examA():
N = I()
ans = 0
print(ans)
return
def examB():
ans = 0
print(ans)
return
def examC():
ans = 0
print(ans)
return
def examD():
#############################################################
class UnionFind():
def __init__(self, n):
... | def examA():
N = I()
ans = 0
print(ans)
return
def examB():
ans = 0
print(ans)
return
def examC():
ans = 0
print(ans)
return
def examD():
#############################################################
class UnionFind():
def __init__(self, n):
... | p03440 |
(n,m),a,*q=[map(int,t.split())for t in open(0)]
t=[-1]*n
def r(x):
while-1<t[x]:x=t[x]
return x
def u(x):
x,y=map(r,x)
if x!=y:
if t[x]>t[y]:x,y=y,x
t[x]+=t[y];t[y]=x
[*map(u,q)]
i=c=0
k,*b=n+~m<<1,
*d,=eval('[],'*n)
for v in a:d[r(i)]+=v,;i+=1
print(k<1and'0'or(k>n)*'Impossible'or exec('for p in... | (n,m,*b),a,*q=[list(map(int,t.split()))for t in open(0)]
t=[-1]*n
def r(x):
while-1<t[x]:x=t[x]
return x
def u(x):
x,y=list(map(r,x))
if x!=y:
if t[x]>t[y]:x,y=y,x
t[x]+=t[y];t[y]=x
[*list(map(u,q))]
i=c=0
k=j=n+~m<<1
*d,=eval('[],'*n)
for v in a:d[r(i)]+=v,;i+=1
for p in d:x,*y=sorted(p)+[0];c+=... | p03440 |
(n,m,*b),a,*q=[list(map(int,t.split()))for t in open(0)]
t=[-1]*n
def r(x):
while-1<t[x]:x=t[x]
return x
def u(x):
x,y=list(map(r,x))
if x-y:
if t[x]>t[y]:x,y=y,x
t[x]+=t[y];t[y]=x
[*list(map(u,q))]
i=c=0
k=j=n+~m<<1
*d,=eval('[],'*n)
for v in a:d[r(i)]+=v,;i+=1
for p in d:x,*y=sorted(p)+[0];c+=x... | (n,m,*b),a,*q=[list(map(int,t.split()))for t in open(0)]
t=[-1]*n
def r(x):
while-1<t[x]:x=t[x]
return x
def u(x):
x,y=list(map(r,x))
if x-y:
if t[x]>t[y]:x,y=y,x
t[x]+=t[y];t[y]=x
[*list(map(u,q))]
i=c=0
k=j=n+~m<<1
*d,=eval('[],'*n)
for v in a:d[r(i)]+=v,;i+=1
for p in d:
if p:x,*y=sorted(p);... | p03440 |
s=sorted
(n,m,*b),a,*q=[list(map(int,t.split()))for t in open(0)]
t=[-1]*n
def r(x):
while-1<t[x]:x=t[x]
return x
def u(x):
x,y=list(map(r,x))
if x-y:
if t[x]>t[y]:x,y=y,x
t[x]+=t[y];t[y]=x
[*list(map(u,q))]
i=c=0
k=j=n+~m<<1
*d,=eval('[],'*n)
for v in a:d[r(i)]+=v,;i+=1
for p in d:
if p:x,*y=... | s=sorted
(n,m,*b),a,*q=[list(map(int,t.split()))for t in open(0)]
t=[-1]*n
r=lambda x:r(t[x])if-1<t[x]else x
def u(x):
x,y=list(map(r,x))
if x-y:
if t[x]>t[y]:x,y=y,x
t[x]+=t[y];t[y]=x
*list(map(u,q)),
i=c=0
k=j=n+~m<<1
*d,=eval('[],'*n)
for v in a:d[r(i)]+=v,;i+=1
for p in d:
if p:x,*y=s(p);c+=x;... | p03440 |
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def unite(self, x, y):
... | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
import heapq
n, m = list(map(int, input().split()))
if m == n-1:
print((0))
exit()
if n < 2*(n-m-1):
print("Impossible")
exit()
A = tuple(map(int, input().split()))
G = [[] for _ in range(n)]
for _ in range(m):
x, y = list(map(... | p03440 |
N,M = list(map(int,input().split()))
src = list(map(int,input().split()))
es = [tuple(map(int,input().split())) for i in range(M)]
if M == N-1:
print((0))
exit()
if M + N//2 < N-1:
print('Impossible')
exit()
parent = [i for i in range(N)]
rank = [0] * N
def root(a):
if parent[a] == a... | N,M = list(map(int,input().split()))
src = list(map(int,input().split()))
es = [tuple(map(int,input().split())) for i in range(M)]
if M == N-1:
print((0))
exit()
if M + N//2 < N-1:
print('Impossible')
exit()
parent = [i for i in range(N)]
rank = [0] * N
def root(a):
if parent[a] == a... | p03440 |
N = int(eval(input()))
print(((N + 1) // 2))
#sjdjsdajkjkafffjfjfjfjfjjfjf | n = int(eval(input()))
if n % 2 == 0:
print((n//2))
else:
print((n//2 + 1)) | p02759 |
import math
n = int(eval(input()))
print((math.ceil(n/2))) | n = int(eval(input()))
print((int((n+1)/2))) | p02759 |
N = int(eval(input()))
print(((N+1)>>1)) | print(((int(eval(input()))+1)//2)) | p02759 |
import math
print((math.ceil(int(eval(input()))/2))) | print(((int(eval(input()))+1)//2)) | p02759 |
n=int(eval(input()))
if n%2==1:
print((n//2+1))
else:
print((n//2)) | n=int(eval(input()))
print(((n+1)//2)) | p02759 |
from math import ceil
print((ceil(int(eval(input()))/2))) | print((-~int(eval(input()))//2)) | p02759 |
import math
N=int(eval(input()))
print((math.ceil(N/2))) | print(((int(eval(input()))+1)//2)) | p02759 |
import math
print((math.ceil(int(eval(input()))/2))) | print(((-int(eval(input()))//2)*-1)) | p02759 |
import math
N=int(eval(input()))
print((math.ceil(N/2))) | N=int(eval(input()))
print((N//2+N%2)) | p02759 |
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
answer = (N+1) // 2
print(answer)
| # coding: utf-8
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
answer = (N+1) // 2
print(answer)
| p02759 |
S = int(eval(input()))
A = 0
if S % 2 == 1:
A = S // 2 + 1
else:
A = S // 2
print(A) | N = int(eval(input())) #数字
print((N // 2 if N % 2 == 0 else N // 2 + 1)) | p02759 |
import itertools
import math
import fractions
import functools
n = int(eval(input()))
if n % 2 == 1:
print((n//2+1))
else: print((n//2)) | n = int(eval(input()))
print(((n+1)//2)) | p02759 |
N = int(eval(input()))
if N%2==0:
print((N//2))
else:
print((N//2 + 1)) | N = int(eval(input()))
print(((N+1)//2)) | p02759 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.