提交时间:2024-12-05 16:47:18
运行 ID: 58225
n = int(input()) ls = [int(i) for i in input().split()] avg = sum(ls) // n for i in range(n): if i == 0: ls[i] -= avg else: ls[i] -= avg ls[i] += ls[i-1] ls.sort() tot = 0 for x in ls: tot += abs(x - ls[n // 2]) print(tot)