60pts __int128拼尽全力无法战胜|玄关
查看原帖
60pts __int128拼尽全力无法战胜|玄关
1053023
MoLing_111楼主2025/1/21 18:24
#include <bits/stdc++.h>
#define int long long
#define MAXN 1e9
using namespace std;

__int128 dp[1005][1005],ans;
int a[1005][1005];
int n,m;

void print(__int128 x){
	if(x>9){
		print(x/10);
	}
	putchar(x%10+'0');
}

signed main(){
    ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin >> a[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		memset(dp,0,sizeof(dp));
		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(a[i][l]*pow(2,m-len+1)+dp[l+1][r],a[i][r]*pow(2,m-len+1)+dp[l][r-1]);
			}
		}
		ans+=dp[1][m];
	}
	print(ans);
	return 0;
}

rt

2025/1/21 18:24
加载中...