fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define quick() ios_base::sync_with_stdio(false); cin.tie(0);
  5. #define pb push_back
  6.  
  7. int mod=1000000007;
  8. int main(){
  9. int t;cin>>t;
  10. while(t--){
  11. int n,x,k;cin>>n;
  12. int a[n];
  13. for(int &x:a) cin>>x;
  14. cin>>k>>x;
  15.  
  16. auto it=lower_bound(a,a+n,x);
  17. int h=it-a;
  18. for(int i=h-k/2;i<=h+k/2;i++){
  19. if(a[i]!=x) cout<<a[i]<<' ';
  20. }
  21.  
  22. cout<<endl;
  23. }
  24. }
Success #stdin #stdout 0.01s 5532KB
stdin
1
6
1 3 5 7 9 11
2 7
stdout
5 9