Help a Thief!!!
Basic Accuracy: 43.8% Submissions: 796 Points: 1

You have to help a thief to steal as many as GoldCoins as possible from a GoldMine. There he saw N Gold Boxes an each Gold Boxes consists of Ai Plates each plates consists of Bi Gold Coins. Your task is to print the maximum gold coins theif can steal if he can take a maximum of T plates.


Example 1:

T = 3, N = 3 
A[] = {1, 2, 3}
B[] = {3, 2, 1}
The thief will take 1 plate of coins
from the first box and 2 plate of coins
from the second plate. 3 + 2*2 = 7.

Example 2:

T = 0, N = 3 
A[] = {1, 3, 2}
B[] = {2, 3, 1}
The thief can't take any plates.
So he can't steal any coins.


Your Task:
You don't need to read input or print anything. Your task is to complete the function maxCoins() which takes 2 Integers T, and N and two arrays A and B of size N as input and returns the maximum number of gold coins the thief can steal if he can take a maximum of T plates.


Expected Time Complexity: O(N*logN)
Expected Auxiliary Space: O(N)


0 <= T,N <= 104
1 <= A[i] <= 104

1 <= B[i] <= 104

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Help a Thief!!!

Output Window