We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 835692a commit 2cf8a79Copy full SHA for 2cf8a79
BOJ/dynamic_programming/BOJ_11048.py
@@ -0,0 +1,13 @@
1
+n, m = map(int, input().split())
2
+maze = [list(map(int, input().split())) for _ in range(n)]
3
+dp = [[0] * m for _ in range(n)]
4
+dp[0][0] = maze[0][0]
5
+for x in range(n):
6
+ for y in range(m):
7
+ if 0 <= x + 1 < n and 0 <= y + 1 < m:
8
+ dp[x+1][y+1] = max(dp[x+1][y+1], maze[x+1][y+1] + dp[x][y])
9
+ if 0 <= x + 1 < n:
10
+ dp[x+1][y] = max(dp[x+1][y], maze[x+1][y] + dp[x][y])
11
+ if 0 <= y + 1 < m:
12
+ dp[x][y+1] = max(dp[x][y+1], maze[x][y+1] + dp[x][y])
13
+print(dp[n-1][m-1])
0 commit comments