Masked_fool @ 2024-05-30 13:03:04
#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;
}
by ZYLZPP @ 2024-05-30 13:13:51
@Zhuzeyin
dp[105][105]开小了
by Masked_fool @ 2024-05-31 12:32:34
@ZYLZPP 谢谢大佬,过了