#include <iostream> #include <cstdio> #include <algorithm> using namespace std; const int MAX_NUM = 100; /** * 查找--北京邮电大学 * @return */ int main() { int numArr[MAX_NUM]; int n; cin >> n; for (int i = 0; i < n; ++i) { cin >> numArr[i]; } /* * 二分查找之前要先排序 */ sort(numArr, numArr + n); int m; cin >> m; int target; for (int j = 0; j < m; ++j) { cin >> target; //C++内部自带的二分查找 int position = lower_bound(numArr, numArr + n, target) - numArr; if (position != n && numArr[position] == target) { cout << "YES" << endl; } else { cout << "NO" << endl; } } return 0; }