티스토리 뷰
https://www.acmicpc.net/problem/1932
import sys
n = int(sys.stdin.readline())
d = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]
l = 2
for i in range(1, n):
for j in range(l):
if j == 0:
d[i][j] += d[i-1][j]
elif j == len(d[i]) - 1:
d[i][j] += d[i-1][j-1]
else:
d[i][j] += max(d[i-1][j-1], d[i-1][j])
l += 1
print(max(d[n-1]))
'Algorithm > Baekjoon' 카테고리의 다른 글
[백준] 11724 : 연결 요소의 개수 - Python (0) | 2020.04.23 |
---|---|
[백준] 1912 : 연속합 - Python (0) | 2020.04.23 |
[백준] 3085 : 사탕 게임 - Python (0) | 2020.04.21 |
[백준] 1463 : 1로 만들기 - Python (0) | 2020.04.20 |
[백준] 5585 : 거스름돈 - Python (0) | 2020.04.17 |