Facebook
From Scanty Eider, 1 Week ago, written in C++.
Embed
Download Paste or View Raw
Hits: 63
  1. #include <bits/stdc++.h>
  2. using namespace std ;
  3. int main (){
  4. int a ,b , y, x;
  5. vector <int> v ;
  6. cin >> a ;
  7. cin >> b ;
  8. for (int i = 0 ; i < a ;i++){
  9.     cin >> x ;
  10.     v.push_back(x) ;
  11. }
  12. for (int  i = 0 ; i < b ; i++){
  13.     cin >> y ;
  14.  int r = a , l = 0 ;
  15.  while ( r - l > 1 ){
  16. int mid = (l + r) / 2;
  17.     v[mid] > y ? mid = r: mid = l ;
  18. }
  19.  cout << v[l] ;
  20. }
  21.     return 0 ;
  22. }