#include<stdio.h> #include<math.h> #include<string.h> //#include<algorithm> #include <bits/stdc++.h> using namespace std; int num[1000001]; int main() { int T; scanf("%d",&T); while(T--) { int n,x; scanf("%d %d",&n,&x); for(int i=0; i<n; i++) { scanf("%d",&num[i]); } sort(num,num+n); int first=0,end=n-1; int panduan=0; while(first<end) { if(num[first]+num[end]<x) { first++; } else if(num[first]+num[end]>x) { end--; } else { panduan=1; break; } } if(panduan==1) { printf("YES\n"); } else { printf("NO\n"); } } } |
Double click to view unformatted code.