#196. 例题3:最大子段和
例题3:最大子段和
题目描述
给定 n 个整数,求所有连续子段中,和的最大值。如果所有数都是负数,输出 0。输入格式
第一行:一个整数 n(1 ≤ n ≤ 2000)第二行:n 个整数(-105 ≤ a[i] ≤ 105)
输出格式
一个整数,表示最大子段和6
-2 11 -4 13 -5 -220
提示
(解释:子段11 -4 13 的和为 20)
6
-2 11 -4 13 -5 -220
11 -4 13 的和为 20)
By signing up a 大飞信奥 universal account, you can submit code and join discussions in all online judging services provided by us.