#include<iostream> #include<cstring> using namespace std; int a[10000000],b[10000000] = { 0 }; int main() { int t, n, x; cin >> t; while (t--) { //int b[10000000] = { 0 }; //memset(b, 0, sizeof(b)); cin >> n >> x; for (int i = 0; i < n; i++) { cin >> a[i]; b[a[i]]++; } int flag = 0; for (int i = 0; i < n; i++) { if (b[x - a[i]] != 0&&x!=2*a[i]) { flag = 1; break; } else if (b[x - a[i]] >=2) { flag = 1; break; } } if (flag) { cout << "YES" << endl; } else cout << "NO" << endl; } return 0; } |
Double click to view unformatted code.