Can u just modify the program by not using typedef..instead use the pair function directly in the priority queue

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pi;
int main()
{
priority_queue<pi , vector, greater >q;
q.push({1, 5});
q.push({5, 3});
q.push({3, 1});
q.push({5, 2});
q.push({1, 10});
cout<<q.top().first<<" "<<q.top().second<<endl;
return 0;
}

@PoojaSingh22
Ofcourse we can. It would be like this ,

#include <bits/stdc++.h>
using namespace std;

int main()
{
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
    q.push({1, 5});
    q.push({5, 3});
    q.push({3, 1});
    q.push({5, 2});
    q.push({1, 10});
    cout << q.top().first << " " << q.top().second << endl;
    return 0;
} 

The reason we use typedef is that it makes our code shorter and easier to write.

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.