python中的优先队列的写法,记录一下。 n,k=map(int,input().split()) l=list(map(int,input().split())) import heapq heapq.heapify(l) while len(l) > 1 : a=heapq.heappop(l) b=heapq.heappop(l) heapq.heappush(l, a*b+k) print(l[0]%1000000007) 另外读入也可以这样写,学到了 n,k,*l=map(int,open(0).read().split()) 上面的代码不到500ms,下面的代码接近1500...