WA#6#7#9求调
查看原帖
WA#6#7#9求调
745329
Masked_fool楼主2024/5/30 13:03
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int a[1005][1005],dp[105][105],maxn=0;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) for(int j=1;j<=i;j++) cin>>a[i][j];
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=i;j++){
			dp[i][j]=max(dp[i-1][j]+a[i][j],dp[i-1][j-1]+a[i][j]);
		}
	}
	for(int i=1;i<=n;i++) maxn=max(maxn,dp[n][i]);
	cout<<maxn;
	return 0;
} 
2024/5/30 13:03
加载中...