lo = 0
hi = len(a)
while lo < hi:
mid = (lo+hi)/2
if prioityOfx > prioityOfa[mid]: hi = mid
else: lo = mid+1
a.insert(lo, x) is fastest as i know.much faster than using heapq. so become the first one. its bottleneck seems to be this insert operation.
没有评论:
发表评论