Whats wrong with my code?

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

int main()
{
priority_queue pq;
int q,k;
cin>>q>>k;
for(int i=0;i<q;i++)
{
int type,x,y;
cin>>type;
if(type==1)
{
cin>>x>>y;
pq.push(xx + yy);
if(pq.size() > k)
pq.pop();
}
else if(type==2)
{
cout<<pq.top()<<endl;
}
}
return 0;
}

Hello @shubhambarnwal02your syntax for defining the priority queue is not complete.
you should declare the priority queue like this:
priority_queuepq; it will form the min heap.


if you have any doubt you can ask here:
Happy Learning!!

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

int main()
{
priority_queue pq;
int q,k;
cin>>q>>k;
for(int i=0;i<q;i++)
{
int type,x,y;
cin>>type;
if(type==1)
{
cin>>x>>y;
pq.push(xx + yy);
if(pq.size() > k)
pq.pop();
}
else if(type==2)
{
cout<<pq.top()<<endl;
}
}
return 0;
}

Sir , i have written
priority_queue pq;
but when i copy and paste my code , long long int vanished .

sir , why long long int is deleting automatically everytime .

@shubhambarnwal02 whenever you share your code you have to share it by saving it on ide.codingblocks.com .
Happy Learning!!

Sir , please verify my code now . What’s wrong ?

i have given your code after correction only.
when the query is of type 1 then you dont have to print anything then you have to just store but when the query is oftype 2 then only you have to print.
and the logic you are using while printing is also wrong.