Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

空间一维的01背包,内详,转移方程

Posted by lqp18_31 at 2009-07-28 14:12:14 on Problem 2184
    for( int i=1 ; i<=N;  i++)
    {
         if( a[ i ]>0 )
         for( int j=MAX-1 ; j>=a[ i ] ; j--)  
             f[ j ]=max( f[ j ] , f[ j-a[ i ] ]+b[ i ] );
         else{
              a[ i ]=-a[ i ];
              for( int j=0 ; j+a[ i ]<MAX ; j++)
                f[ j ]=max( f[ j ] , f[ j+a[ i ] ]+b[ i ] );
         }
    }

best=max( f[ i ]+i-MID , best );

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator