题解 | #搬水果#
搬水果
https://www.nowcoder.com/practice/e4c775b0f3ee42a4bb72c26d2e1eef8a
while True: try:#哈夫曼树思想 n = int(input()) num = list(map(int, input().split(" "))) sum = 0 num.sort(reverse=True) while len(num) > 1: num.sort(reverse=True) x = num.pop() + num.pop() sum += x num.append(x) print(sum) except: break