Initialize all values to 0
for ( int i = 0 ; i < N + 1 ; i ++ ) for ( int j = 0 ; j < b [ N - 1 ] + 1 ; j ++ ) dp [ i , j ] = 0 ; for ( int i = 0 ; i < N + 1 ; i ++ ) for ( int j = 0 ; j < b [ N - 1 ] + 1 ; j ++ ) pref [ i , j ] = 0 ;