#include<bits/stdc++.h>
using namespace std;
int main(){
int n,x,k;
cin>>n>>x>>k;
int a[n];
priority_queue<pair<int,int>> maxhp;
for(int i=0;i<n;i++){
cin>>a[i];
maxhp.push({abs(a[i]-x),a[i]});
if(maxhp.size()>k){
maxhp.pop();
}
}
while(maxhp.size()>0){
cout<<maxhp.top().second<<" ";
maxhp.pop();
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: