Decrease frequency and push back into priority queue if non - zero frequency
for ( int x = 0 ; x < 3 ; x ++ ) { ar [ x ] = new Tuple < int , int > ( ar [ x ] . Item1 - 1 , ar [ x ] . Item2 ) ; if ( ar [ x ] . Item1 != 0 ) { pq . Add ( ar [ x ] ) ; pq . Sort ( ) ; pq . Reverse ( ) ; } } cnt ++ ; }