SP10228 AMR11A - Magic Grid
Description
Thanks a lot for helping Harry Potter in finding the Sorcerer's Stone of Immortality in October. Did we not tell you that it was just an online game ? uhhh! now here is the real onsite task for Harry. You are given a magrid S ( a magic grid ) having R rows and C columns. Each cell in this magrid has either a Hungarian horntail dragon that our intrepid hero has to defeat, or a flask of magic potion that his teacher Snape has left for him. A dragon at a cell (i,j) takes away |S\[i\]\[j\]| strength points from him, and a potion at a cell (i,j) increases Harry's strength by S\[i\]\[j\]. If his strength drops to 0 or less at any point during his journey, Harry dies, and no magical stone can revive him.
Input Format
N/A
Output Format
N/A