Advertisement
serega1112

Style

Dec 14th, 2020
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. n1 = int(input())
  2. c1 = list(map(int, input().split()))
  3. n2 = int(input())
  4. c2 = list(map(int, input().split()))
  5. n3 = int(input())
  6. c3 = list(map(int, input().split()))
  7. n4 = int(input())
  8. c4 = list(map(int, input().split()))
  9.  
  10. c1.sort()
  11. c2.sort()
  12. c3.sort()
  13. c4.sort()
  14.  
  15. p1 = p2 = p3 = p4 = 0
  16.  
  17. diff = float('inf')
  18. res = '0 0 0 0'
  19.  
  20. while True:
  21.     cur_min = min(c1[p1], c2[p2], c3[p3], c4[p4])
  22.     cur_max = max(c1[p1], c2[p2], c3[p3], c4[p4])
  23.     if (cur_max - cur_min) < diff:
  24.         diff = cur_max - cur_min
  25.         res = ' '.join(map(str, [c1[p1], c2[p2], c3[p3], c4[p4]]))
  26.     if c1[p1] == cur_min and p1 < n1 - 1:
  27.         p1 += 1
  28.     elif c2[p2] == cur_min and p2 < n2 - 1:
  29.         p2 += 1
  30.     elif c3[p3] == cur_min and p3 < n3 - 1:
  31.         p3 += 1
  32.     elif c4[p4] == cur_min and p4 < n4 - 1:
  33.         p4 += 1
  34.     else:
  35.         break
  36.  
  37. print(res)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement