ivnikkk

Untitled

Oct 24th, 2021
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1.         ll n;
  2.         cin >> n;
  3.         vector <ll> a(n);
  4.         for (ll i = 0; i < n; i++) cin >> a[i];
  5.         sort(a.begin(), a.end());
  6.         ll m;
  7.         cin >> m;
  8.         for (ll i = 0; i < m; i++) {
  9.             ll tmp;
  10.             cin >> tmp;
  11.             ll L = -1;
  12.             ll R = n;
  13.             while (R - L > 1) {
  14.                 ll M = (R + L) / 2;
  15.                 (a[M] < tmp ? L : R) = M;
  16.             }
  17.             cout << L+1 << " ";
  18.         }
Advertisement
Add Comment
Please, Sign In to add comment