Skip to content

Commit

Permalink
solve : 1912 연속합
Browse files Browse the repository at this point in the history
  • Loading branch information
wwan13 committed May 22, 2024
1 parent 9fd4e27 commit 0195185
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions python/boj_1912.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import sys

input = sys.stdin.readline


def solution(n, data):
dp = [-1e9 for _ in range(n)]
dp[0] = data[0]
for i in range(1, n):
dp[i] = max(data[i], dp[i-1] + data[i])

return max(dp)


def display_result(answer):
print(answer)


def main():
n = int(input())
data = list(map(int, input().split()))
answer = solution(n, data)
display_result(answer)


main()

0 comments on commit 0195185

Please sign in to comment.