priority queue help needed

help

#1

i am declaring a pair of priority queue ,and adding nunbers such as
1 2,
2 3 ,
2 3,
3 4.
so in priority queue the sequence will be
3 4 , 2 3 , 2 3, 1 2.
i want to pop out 3 such that , at the end
3 3 , 2 3, 2 3,1 2 are left ,
how will i do these in priority query ?
i hv less idea abt PQ, so any help will be helpful , i hv declared it as priority_queue <pair<ll,ll>> pq;
will pq.top pop out 3? the next question is how to decrement 3’s 3 to 2.


#4

so if at the top, the pair has 3 and 4 respectively , i wanna pop out 3 only , and decrement 4 to 3 . how to do that?


#5

thnks brother , it helped a lot actually


#6

welcome. Happy to help! :slight_smile:


#7

you don’t you ask the one who told you to use priority queue?