#include <iostream> #include <algorithm> using namespace std; int cmp(int a, int b) { return a < b ? 1 : 0; } int main() { int t, n, x; cin >> t; while (t--) { cin >> n >> x; int girls[1000000] = { 0 }; // 1000000 for (int i = 0; i < n; ++i) cin >> girls[i]; sort(girls, girls + n, cmp); int low = 0, high = n - 1; int flag = 1; while (high > low) { if (girls[low] + girls[high] == x) { cout << "Yes" << endl; flag = 0; break; } ++low; --high; } if (flag) cout << "No" << endl; } return 0; } |
Double click to view unformatted code.