#include<stdio.h> #include<iostream> #include<algorithm> using namespace std; int compare(int a,int b) { return a<b; } int main() { int t; scanf("%d",&t); while(t--) { int n,x; int flag=0; scanf("%d %d",&n,&x); int a[n],i; for(i=0;i<n;i++) { scanf("%d",&a[i]); } sort(a,a+n,compare); int begin=0,end=n-1; while(begin<end) { if(a[begin]+a[end]<x) begin++; else if(a[begin]+a[end]>x) end--; else { printf("YES\n"); return 0; } } printf("NO\n"); } } |
Double click to view unformatted code.