Advertisement
OIQ

Untitled

OIQ
Aug 30th, 2020
136
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <set>
  5.  
  6. using namespace std;
  7.  
  8. void fastIO() {
  9.     ios_base::sync_with_stdio(false);
  10.     cin.tie(0);
  11.     cout.tie(0);
  12. }
  13.  
  14. int getStick(int k, vector <int> &a) {
  15.     int ind = lower_bound(a.begin(), a.end(), k) - a.begin();
  16.     return ind;
  17. }
  18.  
  19. int main() {
  20.     fastIO();
  21.  
  22.     int n;
  23.     cin >> n;
  24.     set <int> s;
  25.     vector <int> a;
  26.     for (int st, i = 0; i < n; i++) {
  27.         cin >> st;
  28.         s.insert(st);
  29.     }
  30.     while (s.size() > 0) {
  31.         a.push_back(*s.begin());
  32.         s.erase(s.begin());
  33.     }
  34.     //sort(a.begin(), a.end());
  35.     int k;
  36.     cin >> k;
  37.     for (int person, i = 0; i < k; i++) {
  38.         cin >> person;
  39.         cout << getStick(person, a) << "\n";
  40.     }
  41.     return 0;
  42. }
Advertisement
RAW Paste Data Copied
Advertisement