题解 | #子数组最大连续和#

不相邻取数

http://www.nowcoder.com/practice/a2be806a0e5747a088670f5dc62cfa1e

while True:
    try:
        n = int(input())
        nums = list(map(int, input().split()))
        pre, Max = 0, nums[0]
        for n in nums:
            pre = max(pre + n, n)
            Max = max(pre, Max)
        print(Max)
    except:
        break
全部评论

相关推荐

不愿透露姓名的神秘牛友
昨天 18:35
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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