//每次都要在每一层进行取,也就是说层与层之间没有什么关联。x,i和j是区间左右。
//dp[x][i][j] = max(dp[x][i+1][j]+pow(2,n)*a[i][j], dp[x][i][j-1]+pow(2,n)*a[i][j]);
//每次都要在每一层进行取,也就是说层与层之间没有什么关联。x,i和j是区间左右。 //dp[x][i][j] = max(dp[x][i+1][j]+pow(2,n)*a[i][j], dp[x][i][j-1]+pow(2,n)*a[i][j]); #include <bits/stdc++.h> using namespace std; #define int __int128 const int maxn = 88; int a[maxn][maxn]; int dp[maxn][maxn]; inline int read(){ int n; int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9'){ x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); } n=x*f; return n; } void write(int n) { if (n<0) { putchar('-'); n = n*-1; } if (n>9) write(n/10); putchar(n%10+'0'); } signed main() { int n, m; n = read();m = read(); for (int i=1;i<=n;i++) { for (int j=1;j<=m;j++) { a[i][j] = read(); } } int ans = 0; for (int x = 1;x<=n;x++) { int num = m; int number = 1; // memset(dp, 0, sizeof(dp)); for (int j=1;j<=num;j++) number = number*2; for (int len = 1;len<=m;len++) { for (int l=1;l+len-1<=m;l++) { int r = l+len-1; dp[l][r] = max(dp[l+1][r]+number*a[x][l], dp[l][r-1]+number*a[x][r]); } number = number/2; } ans += dp[1][m]; } write(ans); return 0; }