help me in this Q i am getting TLE and wrong answer
Hostel problemmmmmmmmmmm
#include
#include
using namespace std;
int main() {
int n,k;
cin>>n>>k;
sets;
while(n–)
{
int p,x,y;
cin>>p;
if(p==1)
{
cin>>x>>y;
int ans=xx+yy;
s.insert(ans);
}
else
{ int i=0;
for(int x:s)
{
if(i==k-1)
cout<<x<<endl;
i++;
}
}
}
return 0;
}
Hello @Tabrej_786 you should use min priority queue cincept for this question.
if you have read about the priority queue then you should do it otherwise you should first cover these topic and the you should then again try to attempt this.
Happy Learning!!
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.