본문 바로가기
Study/Coding Test

[백준] 1940 - 연속합 Python

by 들숨날숨흡 2023. 6. 29.
728x90

https://www.acmicpc.net/problem/1912

 

import sys

input = sys.stdin.readline

N = int(input())
num = list(map(int, input().rstrip().split(" ")))
dp = [0] * N
dp[0] = num[0]

for i in range(1, N):
    dp[i] = max(num[i], dp[i - 1] + num[i])

print(max(dp))
728x90