Company: Impetus_21nov
Difficulty: medium
Maximize Energy Units Problem Description You gave Wael N apples such that the i-th apple needs A[i] minutes to be eaten. Additionally, consuming the i-th apple will give Wael B[i] energy units. You told Wael that he has only T minutes to consume as many of the apples as he wants. Wael is allowed to eat one apple irrespective of how many minutes it needs in usual time during the T-th minute of consumption. Your task is to find the maximum energy units that Wael can gain in T minutes. Examples Example 1: Input: N = 2, T = 60, A = [10, 100], B = [10, 100] Output: 110 Explanation: Wael can eat the first apple that needs 10 minutes in the first 10 minutes. Then in the last minute he can eat the second apple. Total energy = 10 + 100 = 110. Example 2: Input: N = 2, T = 100, A = [100, 100], B = [100, 100] Output: 100 Explanation: Wael can only eat one apple in the last minute, and he cannot make use of the first 99 minutes. Example 3: Input: N = 3, T = 60, A = [10, 10, 10], B = [10, 20, 30] O