10 条题解

  • 1
    @ 2025-9-21 18:17:30
    #include<bits/stdc++.h>
    #define endl '\n'
    using namespace std;
    const int N=1e5+5,INF=0x3f3f3f3f,MOD=1e9+7;
    const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
    typedef long long LL;
    int t,n,m;
    int main(){
    	ios::sync_with_stdio(false);
    	cin.tie(nullptr);cout.tie(nullptr);
    	cin>>t;
    	while(t--){
    		cin>>n>>m;
    		vector<vector<int>>dp(n+1,vector<int>(m+1));
    		for(int i=1;i<=n;i++)
    			for(int j=1;j<=m;j++){
    				cin>>dp[i][j];
    				dp[i][j]+=max(dp[i-1][j],dp[i][j-1]);
    			}
    		cout<<dp[n][m]<<endl;
    	}
    	return 0;
    }
    
    

信息

ID
1341
时间
1000ms
内存
256MiB
难度
4
标签
递交数
378
已通过
166
上传者