""" 动态规划,连续子序列的最大和 dp[i]为i为结束点的子序列最大和 """ if __name__ == '__main__': n = int(input()) a = [] for _ in range(n): a.append(int(input())) dp = [a[0]] for i in range(1, n): dp.append(max(0, dp[-1]) + a[i]) print(max(dp))
""" 动态规划,连续子序列的最大和 dp[i]为i为结束点的子序列最大和 """ if __name__ == '__main__': n = int(input()) a = [] for _ in range(n): a.append(int(input())) dp = [a[0]] for i in range(1, n): dp.append(max(0, dp[-1]) + a[i]) print(max(dp))