def main(N): if len(N) == 1: return N elif len(N) == 2: if N[0] >= N[1]: return [N[0],1] else: return [1,N[1]] else: M = main(N[:-1]) if abs(1-M[-1]) >= abs(N[-1]-M[-1]): return M+[1] else: return M+[N[-1]] if __name__ == '__main__': N = str(input("请输入数列:")) n = list(map(int,N.split(','))) res = main(n) print(res) print(sum([abs(res[i]-res[i-1]) for i in range(1,len(res))]))