求看代码,头条笔试第二题为何通过是0。。。
代码如下:
# -*- coding:utf-8 -*- import sys n = int(sys.stdin.readline().strip()) seq = [int(num) for num in sys.stdin.readline().strip().split()] seq.sort(reverse=True) max_value = seq[0] last = seq[0] for i in range(1, n): if (max_value + seq[i])*seq[i] > max_value*last: max_value += seq[i] last = seq[i] max_value *= last print(max_value)