def mergeSort(l,r)->None: global arr if l>=r:return new = [] mid = l+r>>1 mergeSort(l,mid) mergeSort(mid+1,r) i = l j = mid + 1 while i <= mid and j <= r: if arr[i]<=arr[j]: new.append(arr[i]) i+=1 else: new.append(arr[j]) j+=1 if i<=mid:new += arr[i:mid+1] if j<=r:new += arr[j:r+1] for i in range(r-l+1):arr[l+i] = new[i] n = int(input()) arr = list(map(int,input().split())) mergeSort(0,n-1) for i in range(n):print(arr[i],end = ' ')
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)