Advertisement
sivan_iut

Untitled

Jul 22nd, 2020
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1. ///HELLO THERE~!
  2. ///CODED BY MD SADMAN MEHEDI SIVAN [IUT CSE(SWE)-19]
  3.  
  4. #include<bits/stdc++.h>
  5. using namespace std;
  6.  
  7. #define FASTIO          ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
  8. #define read            freopen("blue.txt","r",stdin);
  9. #define write           freopen("red.txt","w",stdout);
  10.  
  11. using ll=long long;
  12. using ull=unsigned long long;
  13. const double pi = 2*acos(0.0);
  14.  
  15.  
  16. int main()
  17. {
  18.  
  19.     long long n,m;
  20.     cin>>n>>m;
  21.  
  22.  
  23.     vector<long long>x,y;
  24.     vector<long long>::iterator it;
  25.  
  26.  
  27.     for(ll i=0; i<n; i++)
  28.     {
  29.         ll d;
  30.         cin>>d;
  31.         x.push_back(d);
  32.     }
  33.  
  34.     sort(x.begin(),x.end());
  35.  
  36.     for(ll i=0; i<m; i++)
  37.     {
  38.         ll c;
  39.         cin>>c;
  40.         y.push_back(c);
  41.     }
  42.  
  43.  
  44.     for(ll i=0; i<m; i++)
  45.     {
  46.         it=lower_bound(x.begin(),x.end(),y[i]);
  47.  
  48.         if(it==x.begin() && x[0]==y[i])
  49.         {
  50.             cout<<x[0]<<endl;
  51.  
  52.            x.erase(it);
  53.  
  54.         }
  55.         else if(it==x.begin())
  56.             cout<<"-1"<<endl;
  57.  
  58.         else
  59.         {
  60.             it--;
  61.             cout<<*it<<endl;
  62.  
  63.            x.erase(it);
  64.         }
  65.     }
  66.  
  67.  
  68.  
  69.  
  70.  
  71.     return 0;
  72.  
  73.  
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement