map int input split list map int input split for in range dp -1e18 for

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
x,y = map(int,input().split())
c = [list(map(int, input().split())) for i in range(x)]
dp = [[-1e18]*y for i in range(x)]
dp[0][0] = c[0][0]
for i in range(len(c)):
print(*c[i])
for i in range(x):
for j in range(y):
if i > 0:
dp[i][j] = max(c[i][j]+dp[i-1][j],dp[i][j])
if j > 0:
dp[i][j] = max(c[i][j]+dp[i][j-1],dp[i][j])
print("-----------")
for i in range(len(dp)):
print(*dp[i])
print(dp[x-1][y-1])