fork download
  1. //In the name of ALLAH
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. typedef pair<int, int> pii;
  6. typedef long long ll;
  7. typedef pair<ll, ll> pll;
  8. typedef long double ld;
  9.  
  10. int const N = 2e5 + 20;
  11. int n, m, a[N], b[N];
  12. vector <int> v;
  13. map <int, int> mp;
  14.  
  15. int main(){
  16. ios::sync_with_stdio(false); cin.tie(0);
  17. cin >> n >> m;
  18. for (int i = 0 ; i < n ; i ++) cin >> a[i];
  19. for (int i = 0 ; i < m ; i ++) cin >> b[i], v.push_back(b[i]);
  20. sort(v.begin(), v.end());
  21. sort(a, a + n);
  22. for (int i = 0 ; i < v.size() ; i ++){
  23. int x = upper_bound(a, a + n, v[i]) - a;
  24. mp[v[i]] = x;
  25. }
  26. for (int i = 0 ; i < m ; i ++) cout << mp[b[i]] << ' ';
  27. return 0;
  28. }
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
Standard output is empty