The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 4 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Due to do his good deeds, Krishna asked Bheem for a wish. As we know our friend Bheem likes laddus very much so he wished that he wanted to be in a world full of tasty laddus. So, Krishna with his magic sent Bheem to a magical world full of laddus. In this magical world even laddus where magical. There Bheem found that enery that he can gain eating some of the laddus increases every day and those special laddus were placed in a N x M rectangular grid, each cell E[i][j] (1 dth day gives enery equal to d * E[i][j] where E[i][j] is the enery of laddu in the cell (i,j) that can be gained by eating on day 1.
Each day Bheem can only eat all laddus of leftmost column, rightmost column, topmost row or bottommost row of the grid. Help Bheem maximize the overall enery gained by eating the laddus if he starts eating them on day 1.
Â
Â
Â
Â
Input: 1 2 2 1 2 3 4 Output: 21
Example case 1. Initially the grid representing the laddus is : {{1,2},{3,4}}.
Bheem will gain optimal energy, when he will eat the laddus in following order.
On 1st day Bheem eats all laddus of 1st row (topmost row).
Energy gained by Bheem on 1st day = 1+2 = 3
The resultant grid becomes {{3,4}}.
On 2nd day Bheem eats all laddus of 1st column (leftmost column).
Energy gained by Bheem on 2nd day = 2*3 = 6.
The resultant grid becomes {{4}} (there is only 1 element).
On 3rd day Bheem eats the only laddu.
Energy gained by Bheem on 3rd day = 3*4 = 12.
Therefore, the total energy gained by Bheem after eating all the laddus = 3 + 6 + 12 = 21.
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll