binary search
class Solution {\npublic:\n    long long solve(vector& nums1,vector& nums2,long long product)\n    {\n        long long count=0;\n        for(int a:nums1)\n    
class Solution {\npublic:\n    long long solve(vector<int >& nums1,vector<int >& nums2,long long product)\n    {\n        long long count=0;\n        for(int a:nums1)\n        {\n            if(a>0)\n            {\n                int l=0;\n                int h=nums2.size()-1;\n                \n                int temp=-1;\n                while(l<=h)\n                {\n                int mid = l+(h-l)/2;\n                \n                if((long long)a*nums2[mid]<=product)\n                {\n                    temp = mid;\n                    l=mid+1;\n                }\n                else\n                {\n                    h=mid-1;\n                }\n                }\n                count += temp+1;\n            }\n            else\n            {\n                int l=0;\n                int h=nums2.size()-1;\n                int temp=nums2.size();\n                while(l<=h)\n                {\n                    int mid = l+(h-l)/2;\n                    if((long long)a*nums2[mid]<=product)\n                    {\n                        temp = mid;\n                        h=mid-1;\n                    }\n                    else\n                    {\n                        l=mid+1;\n                    }\n                }\n                count += nums2.size()-temp;\n            }\n        }\n        return count;\n    }\n    long long kthSmallestProduct(vector<int>& nums1, vector<int>& nums2, long long k) \n    {\n       long long int low = -1e10;\n       long long int high  = 1e10;\n        \n        long long ans;\n        long long mid;\n        \n        while(low<=high)\n        {\n            mid = low+(high-low)/2;\n            if(solve(nums1,nums2,mid)>=k)\n            {\n                ans = mid;\n                high = mid-1;\n            }\n            else\n            {\n                low = mid+1;\n            }\n        }\n        return ans;\n    }\n};
[]