Stl_priority queue without comparator

priority_queue<pair<int, int> >q;

q.push( {1, 5} );
q.push( {4, 2} );
q.push( {5, 3} );
q.push({2, 4});
q.push({3, 1});
q.push({5, 2});
cout<<q.top().first<<" "<<q.top().second<<endl;
return 0;

Here no comparator is given for pair<int,int> but how can get the q.top() as {5,3}

Hello @poorna883
by default comparator consider first value of pair to perform comparision. and becuase it is max heap.
{5,3} should be the output.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.