#include<iostream> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<algorithm> using namespace std; int main() { long long int t; vector<long long>a; cin >> t; while (t--) { long long int n, x; cin >> n >> x; int q = n; while (n--) { long long int z; cin >> z; a.push_back(z); } sort(a.begin(), a.end()); int low = 0; int high = q - 1; int flag = 0; while (low < high) { if (a[low] + a[high] > x) high--; else if (a[low] + a[high] < x) low++; else { flag = 1; break; } } if (flag == 1) cout << "YES" << endl; else cout << "NO" << endl; a.clear(); } return 0; } |
Double click to view unformatted code.