Problem Statement:
Mustafa wants to cross a dungeon. The dungeon has N cells, and in every cell, there are M monsters. To cross each cell he has to kill one monster, on killing the monster, he loses the strength equal to that of the monster and gains some confidence which adds up to his strength and he proceeds to the next cell. Mustafa can only kill a monster if his strength is greater than or equal to the strength of the monster. Help him find the minimum strength he must have in the beginning so that he can cross N cells.
Input format:
- First two integers are N and M.
- N X M matrix represents the energy required to kill the monster in each cell.
- N X M matrix that represents confidence gained by killing respective monsters.
Testcase:
Input:
3 3
3 2 5
8 9 1
4 7 6
1 1 1
1 1 1
1 1 1
Output:
5
Can someone tell me I can solve this with Dynamic programming?