Limited backpack

I have practiced some codec problems and I am stuck with this problem:

Malvika has created several n contests programs. Each of the contests has three challenges, classified as easy, medium and hard at difficulty. For the i-th competition easy problem takes TE (i) hours and gives you PE (i) pleasure. Likewise, an average problem requires TM (i) hours, gives PM [i] pleasure, and a hard one requires TH (i), PH (i). Today Animesh wanted to practice some of them. Anime has a really bad habit of trying problems for just a few minutes and Malvika: “I'm a nob, you're a professional. Weird shit I don't know. Please tell me please a solution, bro!” Annoyed by this behavior repeatedly in the past, she provided him with special powers that he can use prior to starting practice. Using one power,Animesh can choose any two problems, regardless of their complexity, from two different contests and exchange them. Animesh has a maximum of time before he gets frustrated by his inexplicability and ends up with a practice session. He wants to make the most of it by getting so much fun out of this exercise. Animesh is also pretty boring with contest themes quickly, so he doesn't want to solve more than one problem from any contest. Can you help Anime in assessing the maximum amount of pleasure he can achieve from this activity?Animesh is also pretty boring with contest themes quickly, so he doesn't want to solve more than one problem from any contest. Can you help Anime in assessing the maximum amount of pleasure he can achieve from this activity?Animesh is also pretty boring with contest themes quickly, so he doesn't want to solve more than one problem from any contest. Can you help Anime in assessing the maximum amount of pleasure he can achieve from this activity?


I can identify his limited backpack problem (with weight being the question time and value being the pleasure of the question and the backpack's ability to be the general question solving time), but can't come up with a suitable algorithm to implement the constraint.

Can anyone help me?

+3


source to share





All Articles