Skip to content

Commit 2cf8a79

Browse files
committed
[2023-11-16] BOJ 11048 풀이
1 parent 835692a commit 2cf8a79

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

BOJ/dynamic_programming/BOJ_11048.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)