Advertisement
Guest User

Untitled

a guest
Nov 9th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  4. long long int a[10000000],b[1000001];
  5. int main()
  6. {
  7.     fastio;
  8.     int n, q;
  9.     cin>>n>>q;
  10.     for(int i=0;i<n;i++)
  11.     {
  12.         cin>>a[i];
  13.         b[a[i]]=1;
  14.     }
  15.  
  16.         while(q--)
  17.         {
  18.            long long int tmp;
  19.            cin>>tmp;
  20.            if(b[tmp])
  21.            cout<<lower_bound(a,a+n,tmp)-a<<endl;
  22.            else
  23.             cout<<"-1"<<endl;
  24.         }
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement