DFTD @ 2024-03-05 16:41:02
RT
#include <bits/stdc++.h>
#define maxn 10100
using namespace std;
int r,tot=0,dp[maxn][maxn],a[10100][10100],maxw=-100000;
int main(){
ios::sync_with_stdio(0);
cin>>r;
for(int i=1;i<=r;i++){
for(int j=1;j<=i;j++){
cin>>a[i][j];
tot+=i;
}
}
dp[1][1]=a[1][1];
for(int i=1;i<=r;i++){
for(int j=1;j<=i;j++){
dp[i][j]=max(dp[i-1][j-1]+a[i][j],dp[i-1][j]+a[i][j]);
}
}
for(int i=1;i<=r;i++){
if(dp[5][i]>maxw){
maxw=dp[5][i];
}
}
cout<<maxw<<endl;
return 0;
}
by kevinZ99 @ 2024-03-05 16:49:54
@DFTD
if(dp[5][i]>maxw){
maxw=dp[5][i];
}
不是 dp[5][i]
吧,是 dp[n][i]
吧
by kevinZ99 @ 2024-03-05 16:50:30
@DFTD 没看名字,是 dp[r][i]
。
by DFTD @ 2024-03-05 16:52:50
奥,对的 @kevinZ99
谢谢你
by seika27 @ 2024-03-05 16:53:49
波!
by DFTD @ 2024-03-05 16:54:55
@wzykhp123
奇!
by seika27 @ 2024-03-05 16:55:40
@DFTD 酱!
by tjx114514 @ 2024-03-05 16:56:07
@wzykhp123 boki