n = int(input())
delta = [list(map(int, input().split())) for _ in range(n)]
dp = [[0]*x for x in range(1,n+1)]
print(n)
print(delta)
print(dp)
if n == 1:
print(delta[0][0])
else:
dp[0][0] = delta[0][0]
for i in range(n):
for j in range(i+1):
print(i,j,len(dp[i-1]))
if 0==j:
dp[i][j] = dp[i-1][j] + delta[i][j]
elif len(dp[i-1])==j:
dp[i][j] = dp[i-1][j-1] + delta[i][j]
else:
dp[i][j] = max(dp[i-1][j-1],dp[i-1][j]) + delta[i][j]
print(dp)
print(max(dp[n-1]))
5
7
3 8
8 1 0
2 7 4 4
4 5 2 6 5
[7]
[0, 0]
[0, 0, 0]
[0, 0, 0, 0]
[0, 0, 0, 0, 0]
[7]
[10, 0]
[0, 0, 0]
[0, 0, 0, 0]
[0, 0, 0, 0, 0]
[7]
[10, 15]
[0, 0, 0]
[0, 0, 0, 0]
[0, 0, 0, 0, 0]
[7]
[10, 15]
[18, 0, 0]
[0, 0, 0, 0]
[0, 0, 0, 0, 0]
[7]
[10, 15]
[18, 16, 0]
[0, 0, 0, 0]
[0, 0, 0, 0, 0]
[7]
[10, 15]
[18, 16, 15]
[0, 0, 0, 0]
[0, 0, 0, 0, 0]
[7]
[10, 15]
[18, 16, 15]
[20, 0, 0, 0]
[0, 0, 0, 0, 0]
[7]
[10, 15]
[18, 16, 15]
[20, 25, 0, 0]
[0, 0, 0, 0, 0]
[7]
[10, 15]
[18, 16, 15]
[20, 25, 20, 0]
[0, 0, 0, 0, 0]
[7]
[10, 15]
[18, 16, 15]
[20, 25, 20, 19]
[0, 0, 0, 0, 0]
[7]
[10, 15]
[18, 16, 15]
[20, 25, 20, 19]
[24, 0, 0, 0, 0]
[7]
[10, 15]
[18, 16, 15]
[20, 25, 20, 19]
[24, 30, 0, 0, 0]
[7]
[10, 15]
[18, 16, 15]
[20, 25, 20, 19]
[24, 30, 27, 0, 0]
[7]
[10, 15]
[18, 16, 15]
[20, 25, 20, 19]
[24, 30, 27, 26, 0]
[7]
[10, 15]
[18, 16, 15]
[20, 25, 20, 19]
[24, 30, 27, 26, 24]
30
'Tech > Coding' 카테고리의 다른 글
가장 가까운 두 점 (0) | 2024.03.02 |
---|---|
가장 긴 바이토닉 부분 수열 (0) | 2024.03.02 |
1463번 1로 만들기 (0) | 2024.02.28 |
25494번 단순한 문제 (Small) (0) | 2024.02.27 |
Embedding a Python Playground (0) | 2024.02.26 |