Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///HELLO THERE~!
- ///CODED BY MD SADMAN MEHEDI SIVAN [IUT CSE(SWE)-19]
- #include<bits/stdc++.h>
- using namespace std;
- #define FASTIO ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
- #define read freopen("blue.txt","r",stdin);
- #define write freopen("red.txt","w",stdout);
- using ll=long long;
- using ull=unsigned long long;
- const double pi = 2*acos(0.0);
- int main()
- {
- long long n,m;
- cin>>n>>m;
- vector<long long>x,y;
- vector<long long>::iterator it;
- for(ll i=0; i<n; i++)
- {
- ll d;
- cin>>d;
- x.push_back(d);
- }
- sort(x.begin(),x.end());
- for(ll i=0; i<m; i++)
- {
- ll c;
- cin>>c;
- y.push_back(c);
- }
- for(ll i=0; i<m; i++)
- {
- it=lower_bound(x.begin(),x.end(),y[i]);
- if(it==x.begin() && x[0]==y[i])
- {
- cout<<x[0]<<endl;
- x.erase(it);
- }
- else if(it==x.begin())
- cout<<"-1"<<endl;
- else
- {
- it--;
- cout<<*it<<endl;
- x.erase(it);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement