def solution(triangle):
a = triangle
n = len(a)
# d = [[0] * i for i in range(1, n+1)]
# d[0][0] = a[0][0]
for i in range(1, n):
for j in range(i + 1):
# 맨 왼쪽일 때
if j == 0:
a[i][j] += a[i - 1][0]
elif j == i:
a[i][j] += a[i - 1][j - 1]
else:
a[i][j] += max(a[i - 1][j - 1], a[i - 1][j])
return max(a[n - 1])