1 #include 2 #include 3 4 using namespace std; 5 6 const int N = 110 ; 7 8 int num[N][N]; 9 int f[N][N];10 int n;11 12 int main()13 {14 scanf("%d",&n);15 for(int i=1;i<=n;++i)16 for(int j=1;j<=i;++j)17 scanf("%d",&num[i][j]);18 for(int i=1;i<=n;++i)19 f[n][i]=num[n][i];20 for(int i=n-1;i>=1;--i)21 {22 for(int j=1;j<=i;++j)23 {24 f[i][j] = max(f[i+1][j],f[i+1][j+1])+num[i][j];25 }26 }27 printf("%d",f[1][1]);28 return 0;29 }