fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define pb push_back
  5. #define R return
  6. #define fi first
  7. #define se second
  8. #define yes cout<<"YES\n";
  9. #define no cout<<"NO\n";
  10. const int N=2e5+7;
  11. ll T=1;
  12. void solve()
  13. {
  14. int n,q;
  15. cin >> n >> q;
  16. int a[n+1];
  17. for(int i=1;i<=n;i++){
  18. cin >> a[i];
  19. }
  20. while(q--){
  21. int x;
  22. cin >> x;
  23.  
  24. auto ans = lower_bound(a+1,a+n+1,x)- a ;
  25.  
  26. cout << ans << endl;
  27. }
  28.  
  29. }
  30. int main()
  31. {
  32. ios::sync_with_stdio(NULL);
  33. cin.tie(0);
  34. cout.tie(0);
  35. //cin>>T;
  36. while(T--)
  37. solve();
  38. R 0;
  39. }
Success #stdin #stdout 0s 5316KB
stdin
5 5
3 3 5 8 9
2 4 8 1 10
stdout
1
3
4
1
6