problem
solution
codes
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cstdio>
using namespace std;
typedef long long LL;
typedef __int128 LLL;
const int maxn = 110;
int n, m, a[maxn];
LLL t[maxn], f[maxn][maxn], _max, ans;
void print(LLL ans){
if(ans == 0)return ;
else print(ans/10);
putchar(ans%10+'0');
}
int main(){
cin>>n>>m;
t[0] = 1;
for(int i = 1; i <= m; i++)t[i] = t[i-1]*2;
while(n--){
for(int i = 1; i <= m; i++)cin>>a[i];
memset(f, 0, sizeof f);
for(int i = 1; i <= m; i++)
for(int j = m; j >= i; j--)
f[i][j]=max(f[i-1][j]+t[m-(j-i+1)]*a[i-1], f[i][j+1]+t[m-(j-i+1)]*a[j+1]);
_max = 0;
for(int i = 1; i <= m; i++)_max = max(_max, f[i][i]+t[m]*a[i]);
ans += _max;
}
if(ans == 0)cout<<"0
";
else print(ans);
return 0;
}