fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4. int n, m;
  5. cin >> n >> m;
  6. vector<int> a(n);
  7. vector<int> b(m);
  8. for(int &x : a){
  9. cin >> x;
  10. }
  11. for(int &y : b){
  12. cin >> y;
  13. }
  14. // Bi > Ai
  15. for(int i=0; i<m; i++){
  16. auto it2 = lower_bound(a.begin(), a.end(), b[i]);
  17. cout << distance(a.begin(), it2) << ' ';
  18. }
  19. }
Success #stdin #stdout 0.01s 5320KB
stdin
6 7
1 6 9 13 18 18
2 3 8 13 15 21 25
stdout
1 1 2 3 4 6 6