题解 | #最大序列和#
最大序列和
https://www.nowcoder.com/practice/df219d60a7af4171a981ef56bd597f7b
while True:#dp思想 try: n = int(input()) num = list(map(int, input().split(' '))) dp = [0 for i in range(n)] dp[0] = num[0] for i in range(1, n): dp[i] = max(num[i], dp[i - 1] + num[i])#dp的含义是末尾为i的最大值 print(max(dp)) except: break