Skip to content

Commit

Permalink
solve : 11048 이동하기
Browse files Browse the repository at this point in the history
  • Loading branch information
wwan13 committed Apr 28, 2024
1 parent 78af853 commit 44e626c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions python/boj_11048.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import sys

input = sys.stdin.readline


def solution(n, m, data):
dp = [[0 for _ in range(m+1)] for _ in range(n+1)]

for i in range(1, n+1):
for j in range(1, m+1):
dp[i][j] = max(dp[i-1][j], dp[i][j-1], dp[i-1][j-1]) + data[i-1][j-1]

return dp[-1][-1]


def display_result(answer):
print(answer)


def main():
n, m = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(n)]
answer = solution(n, m, data)
display_result(answer)


main()

0 comments on commit 44e626c

Please sign in to comment.