超简单 动态规划 可用于入门级
include [HTML_REMOVED]
using namespace std;
const int maxx=600;
int main(){
int n;
int a[maxx][maxx];
memset(a,0,sizeof(a));
cin>> n;
for(int i = 0; i < n; i){
for(int j = 0; j <= i; j){
cin>> a[i][j];
}
}
for(int i = n-1; i >= 0; i–){
for(int j = 0; j <= i;j++){
a[i][j] += max(a[i+1][j], a[i+1][j+1]);
}
}
cout << a[0][0];
return 0;
}