题解 | #连续最大和#
连续最大和
https://www.nowcoder.com/practice/5a304c109a544aef9b583dce23f5f5db
while True:
try:
n=int(input())
nums=list(map(int,input().split(' ')))
if n ==1:
print(nums[0])
for i in range(1,n):
if nums[i-1]>0:
nums[i]+=nums[i-1]
print(max(nums))
except:
break
try:
n=int(input())
nums=list(map(int,input().split(' ')))
if n ==1:
print(nums[0])
for i in range(1,n):
if nums[i-1]>0:
nums[i]+=nums[i-1]
print(max(nums))
except:
break