Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

There are N dishes in a line. You are given two arrays size and taste. For all ) , size, denotes the size of the

There are N dishes in a line. You are given two arrays size and taste. For all ), size, denotes the size of the ith dish and taste ?i denotes the taste of the i ith dish. You are allowed to eat at most M dishes. The satisfaction of eating some dishes is given as follows:
Say if you eat k different dishes, the value of satisfaction will be equal to the sum of the sizes of all k dishes multiplied by the minimum taste among all the k dishes.
Calculate the maximum satisfaction you can get after eating at most M different dishes.
Function description
Complete the function solve. This function takes the following 4 parameters and returns the required answer:
N : Represents the total number of dishes
M: Represents the maximum number of dishes you can eat
size: Represents an array of sizes N denoting the sizes of the dishes
taste: Represents an array of sizes N denoting the tastes of the dishes
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Add. -(6c-4d)/(7c)+(c-10d)/(7c) Simplify your answer as much as pos

Answered: 1 week ago