Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n1 = int(input())
- c1 = list(map(int, input().split()))
- n2 = int(input())
- c2 = list(map(int, input().split()))
- n3 = int(input())
- c3 = list(map(int, input().split()))
- n4 = int(input())
- c4 = list(map(int, input().split()))
- c1.sort()
- c2.sort()
- c3.sort()
- c4.sort()
- p1 = p2 = p3 = p4 = 0
- diff = float('inf')
- res = '0 0 0 0'
- while True:
- cur_min = min(c1[p1], c2[p2], c3[p3], c4[p4])
- cur_max = max(c1[p1], c2[p2], c3[p3], c4[p4])
- if (cur_max - cur_min) < diff:
- diff = cur_max - cur_min
- res = ' '.join(map(str, [c1[p1], c2[p2], c3[p3], c4[p4]]))
- if c1[p1] == cur_min and p1 < n1 - 1:
- p1 += 1
- elif c2[p2] == cur_min and p2 < n2 - 1:
- p2 += 1
- elif c3[p3] == cur_min and p3 < n3 - 1:
- p3 += 1
- elif c4[p4] == cur_min and p4 < n4 - 1:
- p4 += 1
- else:
- break
- print(res)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement