1763: 最大连续子段和
Memory Limit:128 MB
Time Limit:1.000 S
Judge Style:Text Compare
Creator:
Submit:30
Solved:17
Description
给你一个有n个整数的数组 nums ,请你找出其中一个最大的连续子段和(子段和最少包含一个元素),返回其最大和。
例如,给定9个整数的nums数组为[ -2,1,-3,4,-1,2,1,-5,4 ],其中[ 4,-1,2,1]的和为6,是此数组中的最大连续子段和。
例如,给定9个整数的nums数组为[ -2,1,-3,4,-1,2,1,-5,4 ],其中[ 4,-1,2,1]的和为6,是此数组中的最大连续子段和。
Input
第一行是一个整数,表示序列的长度 。
第二行有 个整数,第 个整数表示nums数组的第 个数字。
Output
输出一个数, 为nums数组中的最大连续子段和。
Sample Input Copy
9
-2 1 -3 4 -1 2 1 -5 4
Sample Output Copy
6
HINT
- 对于 的数据,保证 。
- 对于 的数据,保证 ,。