fork(1) download
  1. #include <iostream>
  2. #include<algorithm>
  3. #define ll long long
  4. using namespace std;
  5.  
  6. int main() {
  7. // your code goes here
  8.  
  9. int t;
  10. cin>>t;
  11. while(t--)
  12. {
  13. ll n,q,k;
  14. cin>>n>>q;
  15. ll a[n+1];
  16. for(ll i=1;i<=n;i++)
  17. {
  18. cin>>a[i];
  19. }
  20.  
  21. sort(a,a+n+1);
  22. while(q--)
  23.  
  24. {
  25. cin>>k;
  26. ll *l=lower_bound (a, a+n+1, k);
  27. cout<<l-(a+1)<<endl;
  28. }
  29.  
  30. }
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44. return 0;
  45. }
Success #stdin #stdout 0s 16056KB
stdin
1
5
1 2 3 4 5
1
2
stdout
0