AcWing 3542. 查找
原题链接
简单
作者:
故事里的大魔王
,
2025-01-10 18:08:45
,
所有人可见
,
阅读 1
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int n, m, tmp;
cin >> n;
vector<int> a;
vector<int> b;
for(int i = 0; i < n; ++ i ){
cin >> tmp;
a.push_back(tmp);
}
sort(a.begin(), a.end());
cin >> m;
while(m--){
cin >> tmp;
int l = 0, r = a.size() - 1;
while(l < r){
int mid = l + r >> 1;
if(a[mid] >= tmp) r = mid;
else l = mid + 1;
}
if(a[l] == tmp) cout << "YES" << endl;
else cout << "NO" << endl;
}
return 0;
}