子列表元素之和的最大值 是什么意思
def main():items = list(map(int, input().split()))
overall = partial = items
for i in range(1, len(items)):
partial = max(items, partial + items)
overall = max(partial, overall)
print(overall)
if __name__ == '__main__':
main()def main(): items = list(map(int, input().split())) overall = partial = items[0] for i in range(1, len(items)): partial = max(items, partial + items) overall = max(partial, overall) print(overall)if __name__ == '__main__': main()
没搞明白子列表元素之和是什么意思 [,,,] senooo 发表于 2020-11-4 13:35
[,,,]
输入:1 -2 3 5 -3 2
输出:8
输入:0 -2 3 5 -1 2
输出:9
输入:-9 -2 -3 -5 -3
输出:-2
大佬能问下这几个列表的子列表是什么吗,告诉我一个就行了
谢谢 第一个
,,,,,,[-2,3],[-2,3,5],[-2,3,5,-3],[-2,3,5,-3,2],,,,,,[-3,2]
这里面最大的就是 和为8 senooo 发表于 2020-11-5 09:22
第一个
,,,,,,[-2,3],[-2,3,5],[-2,3,5,-3],[-2 ...
明白了,谢谢啊
页:
[1]