Given cost and profit array of farming pattern. Maximize profit for m months. For capital x only crops with cost below or equal to x can be farmed. Each month you can farm only one crop. Once a crop is farmed it can't be used again. After each crop the total capital becomes x + profit.
Example 1:
Input: cost = [1, 8, 9], profit = [2, 3, 8], capital = 7, m = 2
Output: 17
Explanation: In the begining only crop with cost 1 can be farmed. After first month capital = 7 + 2 = 9.
Next crop 9 should be farmed as profit is max for that to give 9 + 8 = 17. So max profit after 2 months will be 17.Expected time complexity less than O(n2).