If advertisement is taken on i - th minute
dp [ i ] [ 1 ] = time [ i ] ; if ( i - K >= 0 ) { dp [ i ] [ 1 ] += max ( dp [ i - K ] [ 0 ] , dp [ i - K ] [ 1 ] ) ; } } return max ( dp [ M - 1 ] [ 0 ] , dp [ M - 1 ] [ 1 ] ) ; }