백준 - DP (#1912)

Eon·2020년 10월 6일
0

Algorithm

목록 보기
20/70

https://www.acmicpc.net/problem/1912
n개의 정수로 이루어진 임의의 수열이 주어진다. 우리는 이 중 연속된 몇 개의 수를 선택해서 구할 수 있는 합 중 가장 큰 합을 구하려고 한다. 단, 수는 한 개 이상 선택해야 한다.

Code

n = int(input())
a = list(map(int, input().split()))
result = [a[0]]
for i in range(1,n):
    result.append(max(a[i], a[i]+result[i-1]))
print(max(result))
profile
👨🏻‍💻 🏃🏻‍♂️ 🎶

0개의 댓글