fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main() {
  6. // your code goes here
  7. int a, b, i, j, weigh[35], limt[35], count;
  8. cin>>a;
  9. while(a--) {
  10. cin>>b;
  11. count=0;
  12. for(i=0; i<b; i++) cin>>weigh[i];
  13. for(j=0; j<b; j++) cin>>limt[j];
  14. std::stable_sort(weigh, weigh+b);
  15. std::stable_sort(limt, limt+b);
  16. for(i=0, j=0; i<b && j<b; i++) {
  17. while(j<b && weigh[i]>limt[j]) {
  18. j++;
  19. }
  20. if(j<b) {
  21. count++; j++;
  22. }
  23. }
  24. cout<<count<<endl;
  25. }
  26. return 0;
  27. }
Success #stdin #stdout 0s 3436KB
stdin
2
3
10 30 20
30 10 20
5
9 7 16 4 8
8 3 14 10 10
stdout
3
4