Priority Queue Of product of pair

Revision en1, by meiniak, 2019-06-29 00:03:09

I just want to use priority queue with pair of integers such that it stores the maximum product of 2 numbers in descending order . How can i use it in C++ .

For Eg : —

2 5

5 10

3 6

will be save in priority queue as

5 10

3 6

2 5

and if a clash happen , then the first element should be prefer .

Also I was solving this problem using priority queue but getting WA at case 30 , strange RUNTIME error for comparison but it passes using vector of pairs . I just found on the net on how to write custom comparison function for priority queue . Is there any other method without using class or struct .

Tags priority queue, comparison function, runtime error

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English meiniak 2019-06-29 00:03:09 743 Initial revision (published)