A chef prepares food for his customers, and he gets the review ratings. So he multiplies the rating and order of dish to maximize the review-rating sum. So the rating comes in as {-1,3,4}.Therefore he calculates as below: 1(-1)+2(3)+3(4)=17. If he would have dropped the first order it would be 1(3)+2(4)=11. So he decides not to drop it. Likewise test case 2 be {4,-9,0,5,-7}: He drops dish with rating -9,-7 and calculates: 1(4)+2(0)+3(5)=19. So write program logic where he can maximize the sum.
Aucun commentaire:
Enregistrer un commentaire