fork download
  1. #include<bits/stdc++.h>
  2. #pragma GCC optimize("Ofast")
  3. #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
  4. using namespace std;
  5. #define int long long
  6. #define all(x) x.begin(),x.end()
  7. #define pb push_back
  8. #define rall(x) x.rbegin(),x.rend()
  9. const int N=1,mod=998244353,MOD=1e9+7,INF=1e18,inf=1e9;
  10. signed main(){
  11. ios::sync_with_stdio(false);
  12. cin.tie(NULL);
  13. //freopen("input.txt","r",stdin);
  14. //freopen("output.txt","w",stdout);
  15. int testcasescount=1;
  16. cin>>testcasescount;
  17. while(testcasescount--){
  18. int n,k,sum=0,cnt=0;
  19. cin>>n>>k;
  20. int a[n],b[n];
  21. for(int i=0;i<n;i++){
  22. cin>>a[i];
  23. }
  24. for(int i=0;i<n;i++){
  25. cin>>b[i];
  26. }
  27. sort(a,a+n);
  28. sort(b,b+n);
  29. reverse(b,b+n);
  30. int j=0,ans=0;
  31. bool ch=true;
  32. for(int i=0;i<n;i++){
  33. if(a[i]+1>k){
  34. break;
  35. }
  36. int y=k%((k/(a[i]+1))+1);
  37. if(y==0){
  38. break;
  39. }
  40. while(j<n&&b[j]>y){
  41. j++;
  42. if(j==n){
  43. ch=false;
  44. break;
  45. }
  46. else if(j<n&&y>=b[j]){
  47. break;
  48. }
  49. }
  50. if(!ch){
  51. break;
  52. }
  53. else{
  54. j++;
  55. ans++;
  56. }
  57. }
  58. cout<<ans<<'\n';
  59. }
  60. }
  61. //Allahu Akbar
  62.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
0