int128全WA求助
查看原帖
int128全WA求助
220824
yyz1005楼主2022/1/20 08:48

本地样例和#1都对

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
__int128 n,m,a[100];
__int128 dp[100][100];
__int128 in128(){
	__int128 x = 0;
	int f = 1;
	char ch;
	ch = getchar();
	if(ch=='-') f = -1;
	else x = ch-'0';
	ch = getchar();
	while('0'<=ch&&ch<='9'){
		x = x*10+ch-'0';
		ch = getchar();
	}
	return x;
}
void put128(__int128 x){
	if(x<0){
		x = -x;
		cout << "-";
	}
	if(x>9) put128(x/10);
	putchar(x%10+'0');
}

int main(){
	__int128 cnt = 0;
	n = in128(),m = in128();
	for(__int128 i = 1; i <= n; i++){
		for(__int128 j = 1; j <= m; j++) a[j] = in128();
		for(__int128 s = m; s >= 1; s--){
			for(__int128 e = s; e <= m; e++){
				//dp[s][e] = 1000000000000010;
				if(s==e) dp[s][e] = a[s];
				else {
					dp[s][e] = max(a[s]+dp[s+1][e]*2,a[e]+dp[s][e-1]*2);
				}
			}
		}
		cnt+=dp[1][m]*2;
	}
	put128(cnt);
	return 0;
}
2022/1/20 08:48
加载中...