为啥说我解答错误

Handsome_girl 发表于 1年前 · 关联问题 数对之差的最大值

n=int(input()) x=input().split() num=[] for a in x:

num.append(int(a))

Max=max(num)-min(num) print(Max)

lr580 发表于 1年前

参考:

n=int(input()) x=[int(i) for i in input().split()] xl = len(x) xm = [x[-1] for i in range(xl)]#从右往左最小值 for i in range(len(x)-2,-1,-1): if x[i]<xm[i+1]: xm[i] = x[i] else: xm[i] = xm[i+1] #print(xm) dmax=-1 for i in range(xl-1): dtry = x[i]-xm[i+1] if dtry > dmax: dmax = dtry print(dmax)