HEU 8003 LITTLE SHOP OF FLOWERS

/* *************************************
Problem: HEU 8003 LITTLE SHOP OF FLOWERS
Time: 0.0910 s
Memory: 624 k 
Accepted Time: 2009-05-19 17:13:15
Tips: 
http://blog.csdn.net/china8848/archive/2008/01/03/2011749.aspx
*************************************
*/
#include 
< stdio.h >
int  main()
{
    
int  a[ 109 ][ 109 ],b[ 109 ][ 109 ],f,v;
    
int  i,j,k,temp;
    
while (scanf( " %d%d " , & f, & v) != EOF)
    {
        
for (i = 1 ;i <= f;i ++ )
        {
            
for (j = 1 ;j <= v;j ++ )
            {
                scanf(
" %d " , & a[i][j]);
                
if (i == 1 )b[i][j] = a[i][j];
                
else  b[i][j] = f *- 51 ;
            }
        }
        
for (i = 2 ;i <= f;i ++ )
        {
            
for (j = i;j <= v;j ++ )
            {
                
for (k = 1 ;k < j;k ++ )
                
if (b[i - 1 ][k] + a[i][j] > b[i][j])b[i][j] = b[i - 1 ][k] + a[i][j];
            }
        }
        temp
= f *- 51 ;
        
for (i = 1 ;i <= v;i ++ )
        
if (temp < b[f][i])temp = b[f][i];
        printf(
" %d\n " ,temp);
    }
    
return   0 ;
}

你可能感兴趣的:(it)