#include <cstdio> #include <iostream> #include <algorithm> using namespace std; int main(){ int t; cin>>t; for(int i=0;i<t;i++){ int n,x; cin>>n>>x; int kk[n]={0}; int temp; int count=0; for(int j=0;j<n;j++){ cin>>temp; if(temp<=x){ kk[count++]=temp; } } sort(kk,kk+count); int begin=0; int end=count-1; int flag=0; while(begin<end){ if(kk[begin]+kk[end]>x){ end--; } else if(kk[begin]+kk[end]<x){ begin++; } else if(kk[begin]+kk[end]==x){ flag=1; break; } } if(flag){ cout<<"YES"<<endl; } else{ cout<<"NO"<<endl; } } return 0; } |
Double click to view unformatted code.