Insert the end day of the jobs which can be completed on i - th day in a priority queue
while ( index < ranges . size ( ) && ranges [ index ] . first <= i ) { queue . push ( ranges [ index ] . second ) ; index ++ ; }