Advertisement
MathQ_

Untitled

Aug 27th, 2021
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int n;
  7.     cin >> n;
  8.     vector<int> a(n);
  9.     for (auto &el : a) cin >> el;
  10.     sort(a.begin(), a.end());
  11.     vector<int> b = {a[0]};
  12.     for (int i = 1; i < n; ++i) {
  13.         if (a[i] != a[i - 1]) {
  14.             b.push_back(a[i]);
  15.         }
  16.     }
  17.     n = b.size();
  18.     int k, x;
  19.     cin >> k;
  20.     while (k--) {
  21.         cin >> x;
  22.         cout << lower_bound(b.begin(), b.end(), x) - b.begin() << '\n';
  23.     }
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement