Step ( 3 ) - Loop for i = K to N - 1 and do accordingly
for ( int i = K ; i < N ; i ++ ) { if ( pq . top ( ) < vec [ i ] . first ) { total_points = total_points - pq . top ( ) + vec [ i ] . first ; max_rating = max ( max_rating , total_points * vec [ i ] . second ) ; pq . pop ( ) ; pq . push ( vec [ i ] . first ) ; } } return max_rating ; }