SHARE
TWEET

Untitled

a guest Nov 9th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top