сосите письку

1
2
3
4
5
6
7
8
9
N,M=map(int,input().split())
a=[]
b=[[0]*(M+1) for i in range(N+1)]
for i in range(N):
a.append(list(map(int,input().split())))
for i in range(1,N+1):
for j in range(1,M+1):
b[i][j]=a[i-1][j-1] + max(b[i-1][j],b[i][j-1])
print(b[-1][-1])