Advertisement
konchin_shih

c732

Aug 6th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3. #include<algorithm>
  4. #define endl '\n'
  5. using namespace std;
  6. int main() {
  7.     cin.tie(NULL);
  8.     ios::sync_with_stdio(false);
  9.     int a, b;
  10.     while (cin >> a >> b) {
  11.         vector<int> vec(a);
  12.         for (auto& i : vec)
  13.             cin >> i;
  14.         while (b-- && cin >> a)
  15.             cout << (binary_search(vec.begin(), vec.end(), a) ? lower_bound(vec.begin(), vec.end(), a) - vec.begin() + 1 : 0) << endl;
  16.     }
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement