Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
935 views
ZS OA ONCAMPUS

Monica has cooked n dishes and collected the data on the level of satisfaction for all the dishes from a guest.
The guest returns an array, where the ith element of the array is the liking level of the ith dish.
Also, the time taken to cook the ith dish is i. Like-to-time coefficient of a dish is calculated by multiplying the time taken to cook food with its liking level, i.e., input 2[i].
Total like-to-time coefficient is calculated by summing up all individual coefficients of dishes.
You want the total like-to-time coefficient to be maximum.
You can also remove some dishes, in which case, a new coefficient is calculated using the left dishes.
Find the maximum sum of all possible like-to-time coefficients.

Eg.
n = 3
A = [-1,3,4]

1*-1 + 2*3 + 3*4 = 17
If we exclude -1,
Then 1*3 + 2*4 = 11
So, 17 is Max total.
in Online Assessments by Expert (108,190 points) | 935 views

Please log in or register to answer this question.