AcWing 5 II

N vi, wisi i

I1000O(n^3) 1e9

f[i , j ] = max( f[i-1,j] , f[i-1,j-v]+w , f[i-1,j-2v]+2w , f[i-1,j-3v]+3w , …..)

f[i , j-v]= max( f[i-1,j-v] , f[i-1,j-2v] + w , f[i-1,j-2v]+2*w , …..)

1111

11 = 1011(B) = 0111(B) + (11-0111(B)) = 0111(B) + 0100(B)

12012….12

1112440001,0010,0100,0100 , 01

10241025 0110

12440~1111

11 = 0111(B) + (11 – 0111(B)) =0111(B) + 0100(B)

011110001(B)0010(B)0100(B)0~7( 124 0~7 ) , 0~70100(B)( 4 ) 0~1101

11 = 0111(B) + (11 – 0111(B)) =0111(B) + 0100(B)

0111(B)111 ( ) , 1 0000….1 , 0000….10 , 0000….100 read more