Geek is at a book fair. There are total N kinds of books. He has to choose a book of a particular kind and read it loudly as many times as he can in the given time and earn points. Geek knows that reading a book of kind i once needs A_{i} minutes and it will give him B_{i} points. Geek has K minutes for reading books. During this time, he can only read a book of a particular kind as many times as he can so as to maximize his points. But he can not pick books of different kinds, he has to read the same book again and again. Find the maximum points Geek can get. 
Example 1:
Input: 
N = 3, K = 10
A = {3, 4, 5}
B = {4, 4, 5}
Output: 12
Explaination: 
If Geek picks book of first kind he can
read it 3 times, he will get 3*4 = 12 points. 
If Geek picks book of second kind he can 
read it 2 times, he will 2*4 = 8 points.
If Geek picks book of third kind he can 
read it 2 times, he will get 2*5 = 10 points.
So the maximum possible points which he 
can earn in those 10 minutes is 12.
Your Task:
You do not need to read input or print anything. Your task is to complete the function maxPoint() which takes N, K and A and B as input parameters and returns the maximum points Geek can earn.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ N ≤ 10^{5}
1 ≤ K, A_{i}, B_{i} ≤ 10^{9}

Source: geeksforgeeks | Difficulty: EASY
Tags: Data structures

Mathematics

Starter code: #User function Template for python3



class Solution:

    def maxPoint(self, N, K, A, B):

        # code here

Solutions:
class Solution:

	def maxPoint(self, N, K, A, B):
		max1 = 0
		for i in range(N):
			a = K // A[i] * B[i]
			max1 = max(max1, a)
		return max1


class Solution:

	def maxPoint(self, N, K, A, B):
		points = []
		for i in range(N):
			points.append(K // A[i] * B[i])
		points.sort()
		return points[-1]


class Solution:

	def maxPoint(self, N, K, A, B):
		D = []
		for i in range(N):
			J = K // A[i] * B[i]
			D.append(J)
		return max(D)


class Solution:

	def maxPoint(self, N, K, A, B):
		c = []
		for i in range(N):
			c.append(B[i] * (K // A[i]))
		return max(c)


class Solution:

	def maxPoint(self, N, K, A, B):
		TotalPoint = A.copy()
		if N <= 0:
			return 0
		for i in range(0, N):
			TotalPoint[i] = K // A[i] * B[i]
		return max(TotalPoint)


class Solution:

	def maxPoint(self, N, K, A, B):
		point = A.copy()
		for i in range(N):
			point[i] = K // A[i] * B[i]
		return max(point)


class Solution:

	def maxPoint(self, N, K, A, B):
		ans = 0
		cnt = 0
		for i in range(len(A)):
			x = A[i]
			j = 1
			while x * j <= K:
				j += 1
				cnt += 1
			ans = max(ans, cnt * B[i])
			cnt = 0
		return ans


class Solution:

	def maxPoint(self, N, K, A, B):
		x = []
		for i in range(N):
			a1 = K // A[i]
			x.append(a1 * B[i])
		return max(x)


class Solution:

	def maxPoint(self, N, K, A, B):
		ans = 0
		for x in range(0, N):
			numberTimes = int(K / A[x])
			if B[x] * numberTimes > ans:
				ans = B[x] * numberTimes
		return ans


class Solution:

	def maxPoint(self, N, K, A, B):
		points = 0
		for i in range(N):
			new_points = K // A[i] * B[i]
			if points < new_points:
				points = new_points
		return points


class Solution:

	def maxPoint(self, N, K, A, B):
		m = -(int(1000000000.0) + 7)
		for i in range(len(A)):
			t = K // A[i]
			pts = t * B[i]
			m = max(m, pts)
		return m


class Solution:

	def maxPoint(self, N, K, A, B):
		output = 0
		for i in range(N):
			output = max(output, K // A[i] * B[i])
		return output


class Solution:

	def maxPoint(self, N, K, A, B):
		mp = 0
		for i in range(len(A)):
			temp = K // A[i]
			temp *= B[i]
			mp = max(temp, mp)
		return mp


class Solution:

	def maxPoint(self, N, K, A, B):
		max_ = 0
		for index in range(N):
			freq = K // A[index]
			mul = freq * B[index]
			max_ = mul if mul > max_ else max_
		return max_


class Solution:

	def maxPoint(self, N, K, A, B):
		max_point = 0
		for i in range(N):
			value = K // A[i]
			if value * B[i] > max_point:
				max_point = value * B[i]
		return max_point


class Solution:

	def maxPoint(self, N, K, A, B):
		lst = []
		for i in range(N):
			p = 0
			p = K // A[i] * B[i]
			lst.append(p)
		return max(lst)


class Solution:

	def maxPoint(self, N, K, A, B):
		temp_arr = []
		for num in range(N):
			temp_arr.append(K // A[num] * B[num])
		return max(temp_arr)


class Solution:

	def maxPoint(self, N, K, A, B):
		m = 0
		for j in range(N):
			k = K // A[j] * B[j]
			if k > m:
				m = k
		return m


class Solution:

	def maxPoint(self, N, K, A, B):
		a = list(A)
		b = list(B)
		lst = []
		for i in range(N):
			t = K // a[i]
			if t * a[i] <= K:
				c = t * b[i]
				lst.append(c)
		return max(lst)


class Solution:

	def maxPoint(self, N, K, A, B):
		res = []
		for i in range(N):
			temp = K // A[i]
			points = temp * B[i]
			res.append(int(points))
		return max(res)


class Solution:

	def maxPoint(self, N, K, A, B):
		maxp = 0
		points = 0
		for i in range(N):
			points = 0
			time = 0
			while time + A[i] < K:
				points = points + B[i]
				maxp = max(maxp, points)
				time = time + A[i]
		return maxp


class Solution:

	def maxPoint(self, N, K, A, B):
		g = 0
		for i in range(len(A)):
			p = K // A[i] * B[i]
			if p > g:
				g = p
		return g


class Solution:

	def maxPoint(self, n, k, a, b):
		arr = [k // i * j for (i, j) in zip(a, b)]
		return max(arr)


class Solution:

	def maxPoint(self, N, K, A, B):
		arr = [K // i * j for (i, j) in zip(A, B)]
		return max(arr)


class Solution:

	def maxPoint(self, N, K, A, B):
		arr = [K // i * j for (i, j) in zip(A, B)]
		ar = arr.index(max(arr))
		p = A[ar]
		sm = 0
		while p <= K:
			sm += B[ar]
			p += A[ar]
		return sm


class Solution:

	def maxPoint(self, N, K, A, B):
		return max([int(K / A[i]) * B[i] for i in range(len(A))])


class Solution:

	def maxPoint(self, N, K, A, B):
		mx = -1000000
		for i in range(N):
			t = K // A[i]
			mx = max(mx, t * B[i])
		return mx


class Solution:

	def maxPoint(self, N, K, A, B):
		a = []
		j = 1
		for i in range(len(A)):
			while j * A[i] <= K:
				j += 1
			a.append(B[i] * (j - 1))
			j = 1
		return max(a)


class Solution:

	def maxPoint(self, N, K, A, B):
		maxi = -999999
		for i in range(N):
			times = K // A[i]
			maxi = max(maxi, times * B[i])
		return maxi


class Solution:

	def maxPoint(self, N, K, A, B):
		maxt = -999999
		for i in range(N):
			t = K // A[i]
			maxt = max(maxt, t * B[i])
		return maxt


class Solution:

	def maxPoint(self, N, K, A, B):
		max1 = -1
		for i in range(N):
			max1 = max(max1, K // A[i] * B[i])
		return max1


class Solution:

	def maxPoint(self, N, K, A, B):
		a = []
		for i in A:
			a.append(K // i)
		p = [a[i] * B[i] for i in range(len(a))]
		return max(p)


class Solution:

	def maxPoint(self, N, K, A, B):
		d = []
		for i in range(N):
			b = K // A[i]
			d.append(b * B[i])
		return max(d)


class Solution:

	def maxPoint(self, N, K, A, B):
		maxs = -9999999
		for i in range(N):
			times = K // A[i]
			maxs = max(maxs, times * B[i])
		return maxs


class Solution:

	def maxPoint(self, N, K, A, B):
		m = -1
		for i in range(N):
			t = K // A[i]
			m = max(m, t * B[i])
		return m


class Solution:

	def maxPoint(self, N, K, A, B):
		ans = 0
		for ele in zip(A, B):
			t = ele[1] * (K // ele[0])
			ans = max(ans, t)
		return ans


class Solution:

	def maxPoint(self, N, K, A, B):
		c = []
		a = 0
		for i in range(N):
			c.append(B[i] * (K // A[i]))
		for i in range(N):
			if c[i] > a:
				a = c[i]
		return a


class Solution:

	def maxPoint(self, N, K, A, B):
		ans = -1
		for i in range(N):
			count = K // A[i]
			max_val = count * B[i]
			ans = max(ans, max_val)
		return ans


class Solution:

	def maxPoint(self, N, K, A, B):
		curr_max = 0
		for i in range(N):
			x = K // A[i]
			z = x * B[i]
			curr_max = max(curr_max, z)
		return curr_max
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(N, K) = [int(x) for x in input().split()]
		A = input().split()
		B = input().split()
		for i in range(N):
			A[i] = int(A[i])
			B[i] = int(B[i])
		ob = Solution()
		print(ob.maxPoint(N, K, A, B))


class Solution:

	def maxPoint(self, N, K, A, B):
		max_score = 0
		cur_score = 0
		for i in range(N):
			cur_score = K // A[i] * B[i]
			if cur_score > max_score:
				max_score = cur_score
		return max_score
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(N, K) = [int(x) for x in input().split()]
		A = input().split()
		B = input().split()
		for i in range(N):
			A[i] = int(A[i])
			B[i] = int(B[i])
		ob = Solution()
		print(ob.maxPoint(N, K, A, B))


class Solution:

	def maxPoint(self, N, K, A, B):
		cal = []
		for i in range(N):
			cal.append(B[i] * (K // A[i]))
		return max(cal)
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(N, K) = [int(x) for x in input().split()]
		A = input().split()
		B = input().split()
		for i in range(N):
			A[i] = int(A[i])
			B[i] = int(B[i])
		ob = Solution()
		print(ob.maxPoint(N, K, A, B))


class Solution:

	def maxPoint(self, n, k, a, b):
		point = 0
		for i in range(n):
			times = k // a[i]
			point = max(point, times * b[i])
		return point
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(N, K) = [int(x) for x in input().split()]
		A = input().split()
		B = input().split()
		for i in range(N):
			A[i] = int(A[i])
			B[i] = int(B[i])
		ob = Solution()
		print(ob.maxPoint(N, K, A, B))


class Solution:

	def maxPoint(self, n, k, a, b):
		m = []
		for i in range(0, n):
			m.append(b[i] * (k // a[i]))
		return max(m)


class Solution:

	def maxPoint(self, N, K, A, B):
		scores = []
		for x in range(len(A)):
			scores.append(B[x] * (K // A[x]))
		return max(scores)


class Solution:

	def maxPoint(self, N, K, A, B):
		time = []
		res = []
		for i in range(N):
			time.append(K // A[i])
		for i in range(N):
			res.append(time[i] * B[i])
		return max(res)