题解 | #连续最大和#

连续最大和

http://www.nowcoder.com/practice/5a304c109a544aef9b583dce23f5f5db

def lianxu(a):
    size = len(a)
    pre = 0 
    res = a[0]
    for i in range(size):
        pre = max(a[i],pre+a[i])
        res = max(res,pre)
    return res    
    
    
    


n = int(input())
nums = list(map(int,input().split()))

res = lianxu(nums)
print(res)

全部评论

相关推荐

我要娶个什么名:学长你电脑闹鬼了
点赞 评论 收藏
分享
评论
点赞
2
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务