#include<iostream>
#define N 350
using namespace std;
int main()
{
int n,max;
int t[N+1][N+1]={0},dp[N+2][N+2]={0};
cin>>n;
for(int i = 1;i<=n;i++)
for(int j = 1;j<=i;j++) cin>>t[i][j];
max = t[1][1];
for(int i = 1;i<=n+1;i++)
{
for(int j = 1;j<=n+1;j++){
int tmp1,tmp2;
tmp1 = dp[i-1][j-1] + t[i-1][j-1];
tmp2 = dp[i-1][j] + t[i-1][j];
dp[i][j] = (tmp1>tmp2)?tmp1:tmp2;
max = dp[i][j]>max?dp[i][j]:max;
}
}
cout<<max<<endl;
}
POJ3176
最新推荐文章于 2017-07-31 22:40:55 发布