贴一个序列重排吧 。。 n = int(input()) nums = list(map(int,input().split())) nums = sorted(nums) first = [] second = [] for i in range(n//2): first.append(nums[i]) for i in range(n//2,n): second.append(nums[i]) if n % 2: temp = second[1] else: temp = -first[-1] x1 = sum(first) x2 = sum(second) res = 2*(x2-x1) - second[0] - temp print(res)
3 1

相关推荐

喵_coding:年底缺人是短视频营造出来的 而且一般说的也很宽泛 不是特指后端
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务