Type Here to Get Search Results !

Hedger | TCS CodeVita 9 Solution ( Zone 1 ) 2020 | By CodingHumans |

4
Hedger

Problem Description
A hedger is an investor who takes steps to reduce the risks of investmentby doing appropriate research and analysis of stocks. Assume that you are a hedger.

Now you have been given some parameters based on which you have to analyse and pick the correct stocks. You have been assigned a fund that you have to manage in such a way that it should give maximum returns.

According to your research you have a list of stocks for which you know the corresponding profit percentages that you can earn within a certain horizon. Being a hedger you don’t want to put all your eggs in one basket. That’s why you have decided the upper limit in terms of quantity that you will buy.

Given number of stocks, the upper limit on quantity, the amount to be invested, the list of stock prices and list of profit percentages, calculate the maximum profit you can make.


Note: All computation should be up to two digits after the decimal point.

Constraints

0 <= A <= 10^6
1 <= K <= 100
1 <= N <= 10^4

Input

First line contains three space separated integers N K A where N is number of stocks in Market, K is maximum quantity of any particular stock you can buy and A is capital amount you have. Second line contains N space separated decimals denoting the prices of stocks. Third line contains N space separated decimals denoting the profit percentages corresponding to the index of stock prices.

Output

Print the maximum profit that can be earned from the given amount, rounded to the nearest integer.

Examples

Example 1

Input

4 2 100
20 10 30 40
5 10 30 20

Output

26

Explanation

Here, we can select only two stocks of any stocks that we choose to buy. We choose to buy stocks which are priced at 30 and 40 respectively. Before we exhaust our capital maximum profit that can be earned

Profit=2((3030)/100) +1((4020)/100)=26

Example 2

Input

5 3 200
90 25.5 15.5 30.8 18.8
5 10 20 5.5 2.5

Output

20

Explanation

Here, we can select only three stocks of any stocks that we choose to buy. We choose to buy stocks which are priced at 25.5, 15.5 and 30.8 respectively. Before we exhaust our capital maximum profit that can be earned
Profit=3((25.510)/100) +3((15.520)/100)+2((30.85.5)/100)=20.34
Hence, output is 20.




Recommended: Please try your approach on your integrated development environment (IDE) first, before moving on to the solution.

Few words from CodingHumans : Don't Just copy paste the solution, try to analyze the problem and solve it without looking by taking the the solution as a hint or a reference . Your understanding of the solution matters.


HAPPY CODING 😁



Solution
( Python )



If you have any doubts regarding this problem or  need the solution in other programming languages then leave a comment down below . 

Post a Comment

4 Comments
  1. Actually i write a code with a same logic in c++ but it fails in private case. so I think its not accepted code .

    ReplyDelete
  2. I think this problem is solvable by using bounded knapsack method.

    ReplyDelete
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

Top Post Ad

Below Post Ad