NYOJ171 聪明的kk (动态规划复习)

 1 #include<stdio.h>

 2 inline int max(int a,int b){

 3     if(a>b) return a;

 4     return b;

 5 }

 6 int main()

 7 {

 8     int n,m,i,j,c;

 9     int f[21][21]={0};

10     scanf("%d%d",&n,&m);

11     for(i=1;i<=n;i++)

12         for(j=1;j<=m;j++){

13             scanf("%d",&c);

14             f[i][j]=max(f[i-1][j],f[i][j-1])+c;

15         }

16     printf("%d\n",f[n][m]);

17     return 0;

18 } 

 

你可能感兴趣的:(动态规划)