fork download
  1. # your code goes here
  2. t = int(input())
  3. for i in range(0, t):
  4. x = list(map(int, input().strip().split()))
  5. if x:
  6. xL = len(x)
  7. s = 0
  8. for i in x:
  9. s += i
  10. sA = float(s/xL)
  11. m = x[0]
  12. diff = abs(float(x[0] - sA))
  13. for i in x:
  14. if abs(float(i - sA)) < diff:
  15. diff = abs(float(i - sA))
  16. m = i
  17. print(m)
  18. else:
  19. print(0)
Success #stdin #stdout 0.03s 9448KB
stdin
3
4 1 2 3 4 
4 4 3 2 1
4 0 3 2 4
stdout
3
3
3