input
stringlengths
20
127k
target
stringlengths
20
119k
problem_id
stringlengths
6
6
import heapq,sys def main(): input = sys.stdin.readline 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) ans ...
import heapq,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+Bでのベスト枠K個求めるO(XYlogK) AandB = [] for i in range(X): ...
p03078
import heapq,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+Bでのベスト枠K個求めるO(XYlogK) AandB = [] for i in range(X): ...
import heapq,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+Bでのベスト枠K個求めるO(XYlogK) AandB = [] for x in A: for y ...
p03078
import bisect X, Y, X, 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() ans1 = [] ans2 = [] for i in range(min(K,len(A))): for j in range(min(K,len(B))): ans1.append(A[i]+B[j...
from heapq import heappop, heappush X, Y, X, 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) Q = [] heappush(Q,[-1*(A[0]+B[0]+C[0]),(0,0,0)]) mem...
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())) tmp = [] for a in A: for b in B: tmp.append(a + b) ans = [] for ab in tmp: for c in C: ans.append(ab + c) ans.sort(reverse=True) f...
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 = [] for a in A: for b in B: tmp.append(a + b) tmp.sort(reverse=True) tmp = tmp[:K] ans = [] for ab in tmp: for c in C:...
p03078
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemge...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemge...
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[:...
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[:...
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 = [] for a in A: for b in B: AB.append(a + b) AB.sort(reverse=True) AB = AB[:min(30...
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) AB = [] for a in A: for b in B: AB.append(a + b) AB.sort(reverse=True) AB = AB[:mi...
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.sort(reverse=True) A = A[0:K] B.sort(reverse=True) B = B[0:K] for a in A: for b in B: AB.append(a+b) AB.sort(reverse=True) AB = AB[...
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) A = A[0:K] B.sort(reverse=True) B = B[0:K] AB = [a+b for a in A for b in B] AB.sort(reverse=True) AB = AB[0:K] C.sort(reverse=True) ...
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())) ab=[] for x in a: for y in b: ab.append(x+y) ab.sort(reverse=True) if len(ab)>k: ab=ab[:k+1] c.sort() l=0 r=max(ab)+max(c)+1 import bise...
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(min(x,k+1)): for j in range(y): if (i+1)*(j+1)>k: break for l in range(z): ...
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())) AB=[] for i in A: for j in B: heapq.heappush(AB,-i-j) #print(AB) ABC=[] for i in AB: for j in C: heapq.heappush(ABC,i-j) for i in range...
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())) AB=[] for i in A: for j in B: heapq.heappush(AB,-i-j) #print(AB) ABC=[] for i in range(min(K,X*Y)): temp=heapq.heappop(AB) for j in C: ...
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())) AB=[] for i in A: for j in B: heapq.heappush(AB,-i-j) #print(AB) ABC=[] for i in range(min(K,X*Y)): temp=heapq.heappop(AB) 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())) 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 ...
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) ansListab=[] for i in range(x): for j in range(y): ansListab.append(a[i]+b[j]) ansLista...
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) ansListab=[] for i in range(x): for j in range(y): ansListab.append(a[i]+b[j]) ansLista...
p03078
#!/usr/bin/env python3 import sys def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"): # A.sort(reverse=True) # B.sort(reverse=True) AB = [] for a in A: for b in B: AB.append(a+b) AB.sort(reverse=True) C.sort(reverse=True) ...
#!/usr/bin/env python3 import sys def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"): AB = [] for a in A: for b in B: AB.append(a+b) AB.sort(reverse=True) C.sort(reverse=True) AB = AB[:K] C = C[:K] ABC = [] for ab...
p03078
#!/usr/bin/env python3 import sys def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"): import heapq A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) h = [] heapq.heappush(h, [-(A[0]+B[0]+C[0]), 0, 0, 0]) ans = [] used = [[...
#!/usr/bin/env python3 import sys def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"): import heapq A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) h = [] heapq.heappush(h, [-(A[0]+B[0]+C[0]), 0, 0, 0]) ans = [] used = se...
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) t = [] for i in set(range(x)): for j in set(range(y)): for l in set(ra...
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)<=K: ...
p03078
from heapq import heappush, heappop X, Y, Z, K = list(map(int, input().split())) A = [int(s) for s in input().split()] B = [int(s) for s in input().split()] C = [int(s) for s in input().split()] A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) h = [] maxv = A[0] + B[0] + C[0] def inv(v):...
from heapq import heappush, heappop X, Y, Z, K = list(map(int, input().split())) A = [int(s) for s in input().split()] B = [int(s) for s in input().split()] C = [int(s) for s in input().split()] A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) h = [] maxv = A[0] + B[0] + C[0] def inv(v):...
p03078
from heapq import heappush, heappop X, Y, Z, K = list(map(int, input().split())) A = [int(s) for s in input().split()] B = [int(s) for s in input().split()] C = [int(s) for s in input().split()] A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) h = [] maxv = A[0] + B[0] + C[0] def inv(v):...
from heapq import heappush, heappop X, Y, Z, K = list(map(int, input().split())) A = [int(s) for s in input().split()] B = [int(s) for s in input().split()] C = [int(s) for s in input().split()] A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) h = [] maxv = A[0] + B[0] + C[0] def inv(v):...
p03078
import heapq class PriorityQueue: def __init__(self): self.__heap = [] self.__count = 0 def empty(self) -> bool: return self.__count == 0 def dequeue(self): if self.empty(): raise Exception('empty') self.__count -= 1 return heapq...
import heapq class PriorityQueue: def __init__(self): self.__heap = [] self.__count = 0 def empty(self) -> bool: return self.__count == 0 def dequeue(self): if self.empty(): raise Exception('empty') self.__count -= 1 return heapq...
p03078
ri = lambda: int(input()) rl = lambda: list(map(int,input().split())) rr = lambda N: [ri() for _ in range(N)] YN = lambda b: print('YES') if b else print('NO') yn = lambda b: print('Yes') if b else print('No') OE = lambda x: print('Odd') if x%2 else print('Even') INF = 10**18 x,y,z,K=rl() A=rl() B=rl() C=rl...
ri = lambda: int(input()) rl = lambda: list(map(int,input().split())) rr = lambda N: [ri() for _ in range(N)] YN = lambda b: print('YES') if b else print('NO') yn = lambda b: print('Yes') if b else print('No') OE = lambda x: print('Odd') if x%2 else print('Even') INF = 10**18 X,Y,Z,K=rl() A=rl() B=rl() C=rl...
p03078
import sys #import numpy as np s2nn = lambda s: [int(c) for c in s.split(' ')] ss2nn = lambda ss: [int(s) for s in ss] ss2nnn = lambda ss: [s2nn(s) for s in ss] i2s = lambda: sys.stdin.readline().rstrip() i2n = lambda: int(i2s()) i2nn = lambda: s2nn(i2s()) ii2ss = lambda n: [sys.stdin.readline().rstrip() for ...
import sys #import numpy as np s2nn = lambda s: [int(c) for c in s.split(' ')] ss2nn = lambda ss: [int(s) for s in ss] ss2nnn = lambda ss: [s2nn(s) for s in ss] i2s = lambda: sys.stdin.readline().rstrip() i2n = lambda: int(i2s()) i2nn = lambda: s2nn(i2s()) ii2ss = lambda n: [sys.stdin.readline().rstrip() for ...
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=1) B.sort(reverse=1) C.sort(reverse=1) D = [0] * (min(k, x) * min(k, y)) for i in range(min(k, x)): for j in range(min(k, y)): D...
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=1) B.sort(reverse=1) C.sort(reverse=1) D = [] for i in range(min(k, x)): for j in range(min(k, y)): for l in range(min(k, z)): ...
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 = sorted(AB)[::-1] ans = [ab + c for (ab, c) in list(itertools.product(AB[:30...
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...
p03078
from itertools import product, chain 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(" ")))) apb_sorted = sorted([a + b for a, b in product(a, b)]) ans_list = sorted( list(...
from itertools import product, chain 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(" ")))) apb_sorted = sorted([a + b for a, b in product(a, b)])[-k:] ans_list = sorted( ...
p03078
from itertools import product, chain from collections import deque def solver1(a, b, c, k): apb_sorted = sorted([a + b for a, b in product(a, b)])[-k:] ans_list = sorted( list(chain.from_iterable([[_c + ab for ab in apb_sorted] for _c in c[:k]])) ) it = reversed(ans_list) for _ i...
from itertools import product, chain from collections import deque def solver1(a, b, c, k): apb_sorted = sorted([a + b for a, b in product(a, b)])[-k:] ans_list = sorted( list(chain.from_iterable([[_c + ab for ab in apb_sorted] for _c in c[:k]])) ) it = reversed(ans_list) for _ i...
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())) E = [] for i in range(X): for j in range(Y): E.append(A[i] + B[j]) E.sort(reverse=True) F = [] for i in range(min(...
# -*- coding: utf-8 -*- 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) Comb = [] for i in range(X): for j in range(Y): if (i...
p03078
l = [int(x) for x in input().split()] x = [int(x) for x in input().split()] y = [int(x) for x in input().split()] z = [int(x) for x in input().split()] result_l = [] for i in x: for j in y: for k in z: result_l.append(i+j+k) result_l.sort(reverse=True) for ind in range(l[-1]): p...
X, Y, Z, K = map(int, 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) bi_comb = [] for i in A[:K]: for j in B[:K]: bi_comb.append(i+j) bi_comb.sort...
p03078
X, Y, Z, K = map(int, 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) bi_comb = [] for i in A[:K]: for j in B[:K]: bi_comb.append(i+j) bi_comb.sort...
X, Y, Z, K = map(int, input().split()) A = sorted([int(x) for x in input().split()], reverse=True) B = sorted([int(x) for x in input().split()], reverse=True) C = sorted([int(x) for x in input().split()], reverse=True) bi_comb = [] for i in range(min(X, K)): for j in range(min(Y, K)): if (i+1)*(j+1...
p03078
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, produc...
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, produc...
p03078
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, produc...
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, produc...
p03078
x, y, z, k = list(map(int, input().split())) m = [] for _ in range(3): m.append(sorted(list(map(int, input().split())), reverse=True)) def sorted_sum(list_a, list_b): s = [] for x in list_a: for y in list_b: s.append(x + y) return sorted(s, reverse=True) ans = sorted_su...
x, y, z, k = list(map(int, input().split())) m = [] for _ in range(3): m.append(sorted(list(map(int, input().split())), reverse=True)) def sorted_sum(list_a, list_b, limit): s = [] for x in list_a: for y in list_b: s.append(x + y) return sorted(s, reverse=True)[0:limit] ...
p03078
import heapq tmp = list(map(int, input().split())) x = tmp[0] y = tmp[1] z = tmp[2] k = tmp[3] 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) #log = [[[False for _ in range(z)] for...
tmp = list(map(int, input().split())) x = tmp[0] y = tmp[1] z = tmp[2] k = tmp[3] 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) ansl = [] for p in range(x): if p > 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())) S = [] for x in A: for y in B: for z in C: S.append(x+y+z) S.sort(reverse = True) for i in range(K): print((S[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())) S = [] for x in A: for y in B: S.append(x+y) S.sort(reverse = True) S1 = [] for i in range(min(K,X*Y)): for z in C: S1.append(S[i]+z) S1....
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 l in range(z): ans.append(a[i] + b[j] + c[l]) ans.sort(reverse=True) for i in range(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())) ans = [] for i in range(x): for j in range(y): ans.append(a[i]+b[j]) ans.sort(reverse=True) ans = ans[:k] ans2 = [] for i in range(len(ans)): for ...
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) p = [0 for _ in range(x * y)] t = 0 for ai in a: for bi in b: p[t] = ai + bi t += 1 p.sort(reverse=True) q = [0 ...
x, y, z, kk = 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) p = [] for i in range(x): for j in range(y): for k in range(z): if...
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) s = [] for i in A: for j in B: for k in C: s.append(i+j+k) s = s...
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) e = [] s = [] for i in A: for j in B: e.append(i+j) e = sorted(e, reverse=True...
p03078
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())) def f(p,q): return [i+j for j in q for i in p] if x+y<y+z: for i in sorted(f(c,f(a,b)))[::-1][:k]: print(i) elif x+z<y+z: for i in sorted(f(b,f...
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())) def f(p,q): return sorted([i+j for j in q for i in p])[::-1][:k] if x+y<y+z: for i in sorted(f(c,f(a,b)))[::-1][:k]: print(i) elif x+z<y+z: for...
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=sorted(s+t for t in B for s in A)[-1:-K-1:-1] abc=sorted(i+x for i in ab for x in C)[-1:-K-1:-1] print(("\n".join(map(str,abc))))
X, Y, Z, K = list(map(int, input().split())) A = sorted(map(int, input().split())) B = sorted(map(int, input().split())) C = sorted(map(int, input().split())) ab=sorted(s+t for t in B for s in A)[-1:-K-1:-1] abc=sorted(i+x for i in ab for x in C)[-1:-K-1:-1] print(("\n".join(map(str,abc))))
p03078
X, Y, Z, K = list(map(int, input().split())) A = sorted(map(int, input().split())) B = sorted(map(int, input().split())) C = sorted(map(int, input().split())) ab=sorted(s+t for t in B for s in A)[-1:-K-1:-1] abc=sorted(i+x for i in ab for x in C)[-1:-K-1:-1] print(("\n".join(map(str,abc))))
X, Y, Z, K = map(int, input().split()) A = sorted(map(int, input().split())) B = sorted(map(int, input().split())) C = sorted(map(int, input().split())) ab=sorted(s+t for t in B for s in A)[-1:-K-1:-1] abc=sorted(i+x for i in ab for x in C)[-1:-K-1:-1] print(*abc,sep="\n")
p03078
def binary_search_int(ok, ng, test, k, A, B): """ :param ok: solve(x) = True を必ず満たす点 :param ng: solve(x) = False を必ず満たす点 """ while abs(ok - ng) > 1: mid = (ok + ng) // 2 if test(mid, k, A, B): ok = mid else: ng = mid return ok def get...
from itertools import product X, Y, Z, K = list(map(int, input().split())) AB = [] for ab in product(list(map(int, input().split())), list(map(int, input().split()))): AB.append(ab[0] + ab[1]) AB.sort(reverse=True) AB = AB[:K] ABC = [] for abc in product(AB, list(map(int, input().split()))): ABC.append...
p03078
from itertools import product X, Y, Z, K = list(map(int, input().split())) AB = [] for ab in product(list(map(int, input().split())), list(map(int, input().split()))): AB.append(ab[0] + ab[1]) AB.sort(reverse=True) AB = AB[:K] ABC = [] for abc in product(AB, list(map(int, input().split()))): ABC.append...
from itertools import product X, Y, Z, K = list(map(int, input().split())) AB = [] for ab in product(list(map(int, input().split())), list(map(int, input().split()))): AB.append(ab[0] + ab[1]) AB.sort(reverse=True) AB = AB[:min(K,X*Y)] ABC = [] for abc in product(AB, list(map(int, input().split()))): A...
p03078
#!/usr/bin/env python3 (x, y, z, k), a, b, c = [[*list(map(int, o.split()))] for o in open(0)] a.sort(); b.sort(); c.sort() p = a[-1] + b[-1] + c[-1] s, h = {(p, -1, -1, -1)}, [(-p, -1, -1, -1)] from heapq import* def push(i, j, k): global s, h try: t = a[i] + b[j] + c[k] except IndexE...
#!/usr/bin/env python3 (x, y, z, k), a, b, c = [[*list(map(int, o.split()))] for o in open(0)] a.sort(); b.sort(); c.sort() h = [(-(a[-1] + b[-1] + c[-1]), -1, -1, -1)] s = set(h) from heapq import* def push(i, j, k): global s, h try: t = (- (a[i] + b[j] + c[k]), i, j, k) except IndexE...
p03078
from queue import PriorityQueue 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) A.append(-float('inf')) B.sort(reverse=True) B.append(-float('inf')) C.sort(reverse=True) C.append(-float...
from heapq import heappop, heappush from time import time 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) A.append(-float('inf')) B.sort(reverse=True) B.append(-float('inf')) C.sort(r...
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()] ans = [] for aa in a: for bb in b: for cc in c: ans.append(aa+bb+cc) ans....
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()] ab = [] for aa in a: for bb in b: ab.append(aa+bb) ab.sort(reverse=True) abc = [] ...
p03078
from itertools import product import sys input = sys.stdin.readline X, Y, Z, K = list(map(int, input().split())) A = [int(_) for _ in input().split()] B = [int(_) for _ in input().split()] C = [int(_) for _ in input().split()] A = sorted(A)[::-1] B = sorted(B)[::-1] C = sorted(C)[::-1] cnt = 0 Ax = 0 Bx...
X, Y, Z, K = list(map(int, input().split())) A = [int(_) for _ in input().split()] B = [int(_) for _ in input().split()] C = [int(_) for _ in input().split()] A = sorted(A)[::-1] B = sorted(B)[::-1] C = sorted(C)[::-1] List = [] 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 = 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 x in range(X): if x >= K: break for y in range(Y): if x ...
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 x in range(X): if x+1 > K: break for y in range(Y): if (...
p03078
import sys if __name__ == "__main__": (X, Y, Z, K) = list(map(int, sys.stdin.readline().split())) A = list(map(int, sys.stdin.readline().split())) B = list(map(int, sys.stdin.readline().split())) C = list(map(int, sys.stdin.readline().split())) v = [] for a in A: for b in B: ...
import sys if __name__ == "__main__": (X, Y, Z, K) = list(map(int, sys.stdin.readline().split())) A = list(map(int, sys.stdin.readline().split())) B = list(map(int, sys.stdin.readline().split())) C = list(map(int, sys.stdin.readline().split())) A.sort(reverse=True) B.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=[0]*(X*Y) t=0 for i in A: for j in B: AB[t]=i+j t+=1 AB.sort(reverse=True) ABA=AB[0:min(K,X*Y)] D=[0]*(Z*len(ABA)) t=0 for i in ABA: for j in C: D[t]=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(min(X,K)): D=int(K/(i+1))+1 for j in range(min(D,Y,K)): E=int(D/(j+1))+1 for...
p03078
import heapq # heapqライブラリのimport 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) check=[[0,0,0]] lst =[(-(A[0]+B[0]+C[0]),0,0,0)] heapq.heapify(lst) for...
import heapq # heapqライブラリのimport 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) dic={} dic[(0,0,0)]=1 lst =[(-(A[0]+B[0]+C[0]),0,0,0)] heapq.heapify(ls...
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) ma,mb,mc = A[0],B[0],C[0] sA = [a-ma for a in A] + [-10**15] sB = [b-mb for b in B] + [-10**15] sC = [...
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) ma,mb,mc = A[0],B[0],C[0] sA = [a-ma for a in A] + [-10**15] sB = [b-mb for b in B] + [-10**15] sC = [...
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) # 処理済みフラグ confilm = [] q = [(-(A[0] +...
from heapq import heappush, heappop 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) V = set() que = [(-(A[0] + B[0] + C[0]), 0, 0, 0)] V.add((...
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...
from itertools import product 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()] BC = [i+j for i,j in list(product(B,C))] BC.sort(reverse=True) ans = [i+j for i,j in list(product(BC[:min(3000, X*Y*Z)]...
p03078
x, y, z, k = list(map(int, input().split())) a = list(int(i) for i in input().split()) b = list(int(i) for i in input().split()) c = list(int(i) for i in input().split()) sums = [] for i in range(x): for j in range(y): for l in range(z): sums.append(a[i] + b[j] + c[l]) sums.sort() ...
x, y, z, k = list(map(int, input().split())) A = list(int(i) for i in input().split()) B = list(int(i) for i in input().split()) C = list(int(i) for i in input().split()) A.sort() A = A[::-1] B.sort() B = B[::-1] C.sort() C = C[::-1] ABC = [] for a in range(len(A)): for b in range(len(B)): ...
p03078
import heapq x, y, z, k = [ int(v) for v in input().split() ] x_list = sorted([ int(v) for v in input().split() ], reverse = True) y_list = sorted([ int(v) for v in input().split() ], reverse = True) z_list = sorted([ int(v) for v in input().split() ], reverse = True) check_list = [ [ [ False for i in range(x) ] f...
import heapq x, y, z, k = [ int(v) for v in input().split() ] x_list = sorted([ int(v) for v in input().split() ], reverse = True) y_list = sorted([ int(v) for v in input().split() ], reverse = True) z_list = sorted([ int(v) for v in input().split() ], reverse = True) cake_list = [] num_set = set([0]) def ...
p03078
ma = lambda :map(int,input().split()) lma = lambda :list(map(int,input().split())) tma = lambda :tuple(map(int,input().split())) ni = lambda:int(input()) yn = lambda fl:print("Yes") if fl else print("No") import collections import math import itertools import heapq as hq ceil = math.ceil x,y,z,k = ma() A = l...
ma = lambda :map(int,input().split()) lma = lambda :list(map(int,input().split())) tma = lambda :tuple(map(int,input().split())) ni = lambda:int(input()) yn = lambda fl:print("Yes") if fl else print("No") import collections import math import itertools import heapq as hq ceil = math.ceil x,y,z,k = ma() A = l...
p03078
from bisect import bisect_left 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*Z <= 10**10: D = sorted([A[i]+B[j]+C[k] for i in range(X) for j in range(Y) for k in range(Z)],reverse=True) for i in range(K): ...
from bisect import bisect_left 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*Z <= 50000: D = sorted([A[i]+B[j]+C[k] for i in range(X) for j in range(Y) for k in range(Z)],reverse=True) 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())) a.sort(reverse=True) b.sort(reverse=True) c.sort(reverse=True) d = [] for e1 in a: for e2 in b: d.append(e1+e2) d.sort(reverse=True) d = d[: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) d = [e1+e2 for e1 in a for e2 in b] d.sort(reverse=True) d = d[:k] e = [e1+e2 for e1 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) d = [e1+e2 for e1 in a for e2 in b] d.sort(reverse=True) d = d[:k] e = [e1+e2 for e1 in ...
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) d = [e1+e2 for e1 in a for e2 in b] d.sort(reverse=True) d = d[:k] e = [e1+e2 fo...
p03078
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(" "))) lst = [x + y + z for x in xs for y in ys for z in zs] lst_s = sorted(lst) for i in range(K): print((lst_s[-(i+1)]))
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 = sorted([x+y for x in xs for y in ys], reverse=True)[:K] xyz = sorted([w+z for w in xy for z in zs], reverse=True) for i in range(K): p...
p03078
import sys import heapq # \n def input(): return sys.stdin.readline().rstrip() 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...
import sys # \n def input(): return sys.stdin.readline().rstrip() 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)...
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 = [] ans = [] for i in range(x): for j in range(y): ab.append(a[i]+b[j]) ab.sort(reverse=True) if len(ab) < k: for i in range(len(ab))...
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())) mid = [] for i in range(x): for j in range(y): mid.append(a[i]+b[j]) mid.sort(reverse=True) ans = [] for i in range(min(k,len(mid))): ...
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 range(X): for b in range(Y): res.append(A[a] + B[b]) res.sort(reverse=True) result = [] for r in res: ...
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) tmp = [] for x in range(X): for y in range(Y): tmp.append(A[x] + B[y]) tmp.sort(reverse=True) res = [] for ...
p03078
import itertools as it X, Y, Z, K = [int(n) for n in input().strip().split(' ')] A = sorted([int(s) for s in input().strip().split(' ')], reverse=True) B = sorted([int(s) for s in input().strip().split(' ')], reverse=True) C = sorted([int(s) for s in input().strip().split(' ')], reverse=True) AB_best = sorted(...
X, Y, Z, K = [int(n) for n in input().strip().split(' ')] A = sorted([int(s) for s in input().strip().split(' ')], reverse=True) B = sorted([int(s) for s in input().strip().split(' ')], reverse=True) C = sorted([int(s) for s in input().strip().split(' ')], reverse=True) ABC = [] for i, a in enumerate(A): 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(' '))) ab = [] for i in a: for j in b: ab.append(i+j) ab.sort(reverse = True) abc = [] k_1 = min([len(ab), k]) for i in ab: 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(' '))) ab = [] for i in a: for j in b: ab.append(i+j) ab.sort(reverse = True) abc = [] ab = ab[:k+1] k_1 = min([len(ab), k]) for i in ab: ...
p03078
import heapq import sys x, y, z, k = list(map(int, input().split())) a, b, c = (sorted(map(int, sys.stdin.readline().split()), reverse=True) for _ in range(3)) abc = [[[0 for _ in range(z)] for __ in range(y)] for ___ in range(x)] stu = [[-a[0]-b[0]-c[0], 0,0,0]] heapq.heapify(stu) result = [] while k > 0...
import heapq import sys x, y, z, k = list(map(int, input().split())) a, b, c = (sorted(map(int, sys.stdin.readline().split()), reverse=True) for _ in range(3)) abc = {(0,0,0)} stu = [[-a[0]-b[0]-c[0], 0,0,0]] heapq.heapify(stu) result = [] while k > 0: out_p, n, m, l = heapq.heappop(stu) if n+1<...
p03078
x, y, z, k = list(map(int,input().split())) alist = [int(i) for i in input().split()] blist = [int(i) for i in input().split()] clist = [int(i) for i in input().split()] # print(x,y,z,k, alist, blist, clist) #%% # x,y,z,k,alist,blist,clist = 2, 2, 2, 8, [4, 6],[1, 5],[3, 8] #%% alist.sort() blist.sor...
# https://atcoder.jp/contests/abc123/tasks/abc123_d def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) X, Y, Z, K = MAP() A = LIST() B = LIST() C = LIST() # A.sort(reverse=True); B.sort(reverse=True); C.sort(reverse=Tru...
p03078
from heapq import heappush, heappop 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) cake_heap = [] for i in range(len(A)): if i + 1 > ...
from heapq import heappush, heappop 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) h = [] minus_value = -(A[0] + B[0] + C[0]) heappush(h,...
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(len(A)) : for j in range(len(B)) : AB.append(A[i] + B[j]) AB.sort(reverse = True) AB = AB[:K] ABC = [] for i in r...
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 = [0] *(len(A) * len(B)) for i in range(len(A)) : for j in range(len(B)) : AB[len(B) * i + j] = A[i] + B[j] AB.sort(reverse = True) ...
p03078
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=lambda :sys.stdin.readline().rstrip() def resolve(): 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=1) ...
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=lambda :sys.stdin.readline().rstrip() def resolve(): 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())) S=[] T=[] ...
p03078
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=lambda :sys.stdin.readline().rstrip() def resolve(): 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())) S=[] T=[] ...
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=lambda :sys.stdin.readline().rstrip() def resolve(): x,y,z,K=list(map(int,input().split())) A=sorted(map(int,input().split()),reverse=1) B=sorted(map(int,input().split()),reverse=1) C=sorted(map(int,input().split())...
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() B.sort() C.sort() queue = [(A[0]+B[0]+C[0], 0, 0, 0)] flg = [[[0 for i in range(Z)] for j in range(Y)] for k in range(X)]...
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() B.sort() C.sort() queue = [(A[0]+B[0]+C[0], 0, 0, 0)] flg = {} for i in range(K): cake, a, b, c = heapq.heappop(que...
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()] AB = sorted([a + b for a in A for b in B], reverse=True)[:K] ABC = sorted([ab + c for ab in AB for c in C], reverse=True)[:K] for a in ABC: print(a)...
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) a = [] for x in range(X): for y in range(Y): for z in range(Z): ...
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) h = [] heapq.heappush(h, (-(A[0] + B[0] + C[0]), (0, 0, 0))) ans = [] ...
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) h = [] heapq.heappush(h, (-(A[0] + B[0] + C[0]), (0, 0, 0))) ans = [] ...
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(' '))) list.sort(A, reverse=True) list.sort(B, reverse=True) list.sort(C, reverse=True) sums = [] for i in range(X): for j in range(Y): 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(' '))) list.sort(A, reverse=True) list.sort(B, reverse=True) list.sort(C, reverse=True) sums = [] for i in range(X): for j in range(Y): for ...
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())) A.sort(reverse = True) B.sort(reverse = True) C.sort(reverse = True) A += [-1e10] B += [-1e10] C += [-1e10] memo = [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) abc = [] for i in range(X): for j in range(Y): if (i + 1) * (j + 1) > K: ...
p03078
import itertools X, Y, Z, K = 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()))) comb_ab = [] for a, b in itertools.product(A, B): comb_ab.append(sum([a, b])) comb_ab_top = sorted(comb_ab, revers...
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) comb = [] for a in range(X): b_max = K // (a+1) for b in range(min(Y, b_max)): c_...
p03078
from collections import OrderedDict 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) max_b = max(B) max_c = max(C) summs_ab = [] summs =...
from collections import OrderedDict 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) """ max_b = max(B) max_c = max(C) """ summs_ab = [...
p03078
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...
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) result = [] 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=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=1 b=1 c=1 A.append(-10**11) B.append(-10**11) C.append(-10**11) A.insert(0,-10**11) B.insert(0,-10**11) 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())) AB=[] for a in A: for b in B: AB.append(a+b) AB=sorted(AB,reverse=True)[:k] ABC=[] for ab in AB: for c in C: ABC.append(ab+c) ABC.sort(reverse=Tr...
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 bisect import bisect_left, bisect_right def C(x): # count "abc <= x" ret = 0 for aa in a: for bb ...
if __name__ == '__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())) bc = [] for bb in b: for cc in c: bc.append(bb + cc) bc.sort() from bi...
p03078
# coding: utf-8 # Your code here! x,y,z,k = list(map(int,input().split())) A = sorted(map(int,input().split()))[::-1] B = sorted(map(int,input().split()))[::-1] C = sorted(map(int,input().split()))[::-1] AB = sorted([a+b for a in A for b in B])[::-1] ans = sorted([ab + c for ab in AB for c in C])[::-1] ...
# coding: utf-8 # Your code here! x,y,z,k = list(map(int,input().split())) A = sorted(map(int,input().split()))[::-1] B = sorted(map(int,input().split()))[::-1] C = sorted(map(int,input().split()))[::-1] AB = sorted([a+b for a in A for b in B])[::-1] ans = sorted([ab + c for ab in AB[:k] for c in C])[::-...
p03078
x,y,z,k = list(map(int,input().split())) A = sorted(map(int,input().split()))[::-1] B = sorted(map(int,input().split()))[::-1] C = sorted(map(int,input().split()))[::-1] AB = sorted([a+b for a in A for b in B])[::-1] ans = sorted([ab + c for ab in AB[:k] for c in C])[::-1] for i in ans[:k]: print...
# coding: utf-8 # Your code here! x,y,z,k = list(map(int,input().split())) A = sorted(map(int,input().split()))[::-1] B = sorted(map(int,input().split()))[::-1] C = sorted(map(int,input().split()))[::-1] AB = [a+b for a in A for b in B] AB.sort(reverse = True) ans = [ab + c for ab in AB[:k] for c in C] ...
p03078
import itertools 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) AB = [] for p in itertools.product(A, B): AB.append(sum(p)) AB = sor...
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())) A.sort(reverse=True) B = list(map(int, input().split())) B.sort(reverse=True) C = list(map(int, input().split())) C.sort(reverse=True) AB = [] for b in B: for a in A: AB.append(a+b) AB = sorted(AB, reverse=True)[:K...
X, Y, Z, K = list(map(int, input().split())) A = list(map(int, input().split())) A.sort(reverse=True) B = list(map(int, input().split())) B.sort(reverse=True) C = list(map(int, input().split())) C.sort(reverse=True) AB = [] ABC = [] for b in B: for a in A: AB.append(a+b) AB.sort(reverse=True) ...
p03078
X, Y, Z, K = list(map(int, input().split())) A = list(map(int, input().split())) A.sort(reverse=True) B = list(map(int, input().split())) B.sort(reverse=True) C = list(map(int, input().split())) C.sort(reverse=True) AB = [] for b in B: for a in A: AB.append(a+b) AB.sort(reverse=True) AB = AB[:...
X, Y, Z, K = list(map(int, input().split())) A = list(map(int, input().split())) A.sort(reverse=True) B = list(map(int, input().split())) B.sort(reverse=True) C = list(map(int, input().split())) C.sort(reverse=True) ABC = [] for xi in range(X): if xi+1 > K: break for yi in range(Y): ...
p03078
#!/usr/bin/env python3 import sys import itertools def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"): A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) com = list( itertools.product(A,B,C) ) S = list([sum(c) for c in com]) S.s...
#!/usr/bin/env python3 import sys import itertools def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"): A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) AB = list( itertools.product(A,B) ) ABS = list([sum(c) for c in AB]) ABS.s...
p03078
#!/usr/bin/env python3 import sys import itertools def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"): AB = list( itertools.product(A,B) ) ABS = list([sum(c) for c in AB]) ABS.sort(reverse=True) ABS2 = ABS[0:K] ABC = list( itertools.product(ABS2...
#!/usr/bin/env python3 import sys import itertools def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"): A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) ABC = [] for x in range(X): for y in range(Y): if ((x+1)*(y...
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) ans = [] check = [[[False for i in range(K)] for j in range(K)] for k in range(K)] q = [[0, 0...
import sys input = sys.stdin.readline 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) ind = [] for 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())) a.sort(reverse=True) b.sort(reverse=True) c.sort(reverse=True) l1 = [] for i in a: for j in b: l1.append(i+j) #print(l1) l2 = [] l1.sort(rever...
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 = [] for i in a: for j in b: l1.append(i+j) #print(l1) l2 = [] l1.sort(rever...
p03078
from itertools import product 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) candidates = [] for i, j, k in product(list(range(len(A))), l...
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) candidates = [] for i in range(len(A)): for j in range(len(B)): for k in range(l...
p03078
# -*- coding: utf-8 -*- ############# # Libraries # ############# import sys input = sys.stdin.readline import math #from math import gcd import bisect import heapq from collections import defaultdict from collections import deque from collections import Counter from functools import lru_cache ###...
# -*- coding: utf-8 -*- ############# # Libraries # ############# import sys input = sys.stdin.readline import math #from math import gcd import bisect import heapq from collections import defaultdict from collections import deque from collections import Counter from functools import lru_cache ###...
p03078
import itertools 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 = [a + b for (a, b) in list(itertools.product(A, B))] AB.sort(reverse = True) ans = [ab + c for (ab, c) in list...
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 = [] for a in A: for b in B: l.append(a+b) l = sorted(l, reverse = True)[:K] an...
p03078
from bisect import insort 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) for i in range(Z-1, 0, -1) : C[i] -= C[i-1] n = [] fo...
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) s = [] for x in range(X) : for y in range(Y) : s.append(A[x]+B[y]) s.sort...
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())) l = [] for p in range(0,x): for q in range(0,y): for r in range(0,z): if len(l) > k: heapq.heappushpop(l,...
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) l = [] for p in range(0,x): for q in range(0,y): for r in ran...
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(reverse=True); B.sort(reverse=True); C.sort(reverse=True) ans = [] for i in A: for j in B: for l in C: ans.append(i...
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) ans = [] for i in A: for j in B: ans.append(i+j) ans.sort(reverse=Tru...
p03078
N = list(map(int, input().split()))[-1] A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) first = [i+j for i in A for j in B] first = sorted(first)[::-1] second = [i+j for i in first for j in C] print(("\n".join([str(value) for value in sorted(second)...
N = list(map(int, input().split()))[-1] A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) first = [i+j for i in A for j in B] first = sorted(first)[::-1] second = [first[i]+j for i in range(len(first)) for j in C if i <= N] print(("\n".join([str(value...
p03078
N = list(map(int, input().split()))[-1] A = sorted(list(map(int, input().split())), reverse=True)[:N] B = sorted(list(map(int, input().split())), reverse=True)[:N] C = sorted(list(map(int, input().split())), reverse=True)[:N] result = [A[i]+B[j]+C[k] for i in range(len(A)) for j in range(l...
N = list(map(int, input().split()))[-1] A = sorted(list(map(int, input().split())), reverse=True)[:N] B = sorted(list(map(int, input().split())), reverse=True)[:N] C = sorted(list(map(int, input().split())), reverse=True)[:N] first = [i+j for i in A for j in B] first = sorted(first, reverse=True)[:N] second = [...
p03078
''' Created on 2020/09/08 @author: harurun ''' def main(): import sys pin=sys.stdin.readline pout=sys.stdout.write perr=sys.stderr.write X,Y,Z,K=list(map(int,pin().split())) A=list(map(int,pin().split())) B=list(map(int,pin().split())) C=list(map(int,pin().split())) # A.sort(reverse=T...
''' Created on 2020/09/08 @author: harurun ''' def main(): import sys pin=sys.stdin.readline pout=sys.stdout.write perr=sys.stderr.write X,Y,Z,K=list(map(int,pin().split())) A=list(map(int,pin().split())) B=list(map(int,pin().split())) C=list(map(int,pin().split())) # A.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())) A.sort(reverse = True) B.sort(reverse = True) C.sort(reverse = True) ans = [] ApB = [] for i in range(min(X, K)): for j in range(min(Y, K)): ApB...
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(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())) A = sorted(A,reverse = True) B = sorted(B,reverse = True) C = sorted(C,reverse = True) AB = [] ABC = [] for i in A: for j in B: AB.ap...
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())) A = sorted(A, reverse=True)[:K+1] B = sorted(B, reverse=True)[:K+1] C = sorted(C, reverse=True)[:K+1] res = [] for i in A: for j in B: 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 = sorted(A, reverse=True)[:K+1] B = sorted(B, reverse=True)[:K+1] C = sorted(C, reverse=True)[:K+1] res = [] for i in A: for j in B: res....
p03078