课本例题
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int d[4][4];
int a[4][4]={{1},{3,2},{4,10,1},{4,3,2,20}};
int solve(int i,int j){
if(d[i][j]>=0) return d[i][j];
return
d[i][j]=a[i][j]+(i==4?0:max(solve(i+1,j),solve(i+1,j+1)));
}
int main(){
int i,j;
memset(d,-1,sizeof(d));
for(j=0;j<4;j++) d[3][j]=a[3][j];
printf("%d\n",solve(0,0));
return 0;
}