AdvancedRating 1600
Enough Health for the Dungeon
A knight starts in the top-left room and must reach the bottom-right, moving only right or down. Each room changes his health by its value. His health must stay at least 1 at all times. Print the least starting health.
Input
r and c, then r rows.
Output
One integer.
Sample 1
Input
3 3 -2 -3 3 -5 -10 1 10 30 -5
Output
7
Sample 2
Input
1 1 0
Output
1
Output appears here