数字金字塔3条路 f[i][j]=max(max(f[i-1][j],f[i-1][j-1]),f[i-1][j+1])+a[i][j];
#include<bits/stdc++.h>
using namespace std;
const int INF=10000000;
int mp[205][205];
int dp[205][205];
int main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++)
scanf("%d",&mp[i][j]);
}
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++){
dp[i][j]=max(dp[i-1][j-1],max(dp[i-1][j],dp[i-1][j+1]))+mp[i][j];
}
int x=n;
int y=m/2+1;
cout<<max(dp[x][y],max(dp[x][y-1],dp[x][y+1]))<<endl;
return 0;
}