import heapqimport mathdef aa(nums): mid=math.ceil(len(nums)/2) q=heapq.nlargest(mid,nums)[-1] m=heapq.nsmallest(mid,nums)[-1] return (m+q)/2print(aa([1,2,3,3,4,5]))
本文共 235 字,大约阅读时间需要 1 分钟。
import heapqimport mathdef aa(nums): mid=math.ceil(len(nums)/2) q=heapq.nlargest(mid,nums)[-1] m=heapq.nsmallest(mid,nums)[-1] return (m+q)/2print(aa([1,2,3,3,4,5]))
转载于:https://www.cnblogs.com/xzm123/p/9856715.html