To store advertising value at i - th minute
var time = Array ( M ) . fill ( 0 ) ; for ( var i = 0 ; i < N ; i ++ ) { time [ array [ i ] [ 0 ] ] = array [ i ] [ 1 ] ; } var dp = Array . from ( Array ( M ) , ( ) => Array ( 2 ) ) ;