it had already being provided in the comment, “pair using static array”
Oops, I hadn’t noticed, sorry. Will have to get rid of my habit of using vectors I guess, could you suggest a few tutorials on BITs, and network flow?
“We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil” , remember that and start using vectors again , 
- http://ayurjain.blogspot.in/ His tutorials are good…
- MAXimal :: algo
- Basic Binary Indexed Tree (English version) - Codeforces
1 Like
The compare function, compares the second element of pair and returns true to sort function if p1.second>p2.second otherwise false, based on these boolean values, sort function judges the position of the pair in array. If you are not clear with Sorting function read regd merge sort : Merge sort - Wikipedia
Thank you!