Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- signed main()
- {
- int n , q , x;
- cin >> n >> q;
- vector<int> a(n);
- for(int i = 0; i < n; i++){
- cin >> a[i];
- }
- while(q--){
- cin >> x;
- int l = 0 , r = n - 1;
- while(l < r){
- int mid = (l + r) / 2;
- if(a[mid] < x){
- l = mid + 1;
- }else{
- r = mid;
- }
- }
- //l == r
- cout << ((a[l] == x) ? "YES" : "NO") << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement