第一题预处理每行的最大值。 第二题没写完。。。。 暴力不知道能不能过,哪位大佬给测一下 tree=[1,2,3,4,5,6,7] n=7 k=2 for j in range(k): for i in range(n): if i%2==0: if i*2+1>=n: continue t=i temp=tree[i] while t*2+1<n: tree[t]=tree[t*2+1] t=t*2+1 tree[t]=temp print(tree)