Time limit: 3.0s
Memory limit: 64M
You are given an grid of squares. Each square contains a number , , the cost to travel through that square. You are starting at the most top-left square. At each turn you may choose to move down or right but not both. Find the minimum cost it would take you to travel to the most bottom-right square.
In all tests,
The first line contains two integers, and , the dimensions of the grid of squares ( rows and columns).
The next lines each contains integers, , the cost to travel through that square in the grid.
Output on a single line, the minimum sum of costs to travel from the most top-left square to the most bottom-right square.
3 4 3 1 2 4 9 8 7 6 2 8 9 2
Explanation for Sample Output
We can take the path , which gives us the sum of . There are no paths that yield a smaller sum.