My code compiles successfully but no output is printed.
Here’s one approach
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
vector<int> v;
int type;
cin>>type;
for( int q= 0; q<n; q++)
{
if (type==1)
{
int x,y;
cin>>x>>y;
int dist = x*x + y*y;
v.push_back(dist);
}
if (type==2)
{
int temp = v[q-1];
for( int i=1; i<k; i++)
{
if(v[q-k-1]<temp)
{
temp = v[q-k-1];
}
}
cout<<temp<<"\n";
}
}
}
The other approach was using a heap. But, could you suggest how to keep the size of a heap fixed (liked 3).