1193: 最大连续子串和

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:7 Solved:6

Description

已知一个长为n的整数数组a,其数据元素-100000 < a[i] < 100000
找到一个数组的最长连续子串和
连续子串和的概念是,数组的某一个连续子串,子串的所有值之和
例如:输入:[-2,1,-3,4,-1,2,1,-5,4
[-2,1,-3]、[4,-1,2,1]等均为其子串
最大子连续子串:[
4,-1,2,1

最大连续子串和:6

Input

第一行数字1<= n <=1000
第二行n个整数

Output

最大连续子串和

Sample Input Copy

9
-2 1 -3 4 -1 2 1 -5 4

Sample Output Copy

6

Source/Category