I have tried to use pbds ds in the question i am getting wrong testcase 4 I don’t know why.
@apaarkamal can you please help.
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl “\n”
#define pb push_back
#define ll long long int
#define testcases int t;cin>>t;while(t–)
typedef tree<ll, null_type, less, rb_tree_tag,
tree_order_statistics_node_update>
PBDS;
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int main()
{
fastio();
int n,k;
cin>>n>>k;
k–;
PBDS pbds;
for(int i=0;i<n;i++){
int q;
cin>>q;
if(q==1){
ll x,y;
cin>>x>>y;
pbds.insert((x * x+y * y));
}else {
cout<<*pbds.find_by_order(k)<<endl;
}
}
}