This is a programming problem.
Suppose we have an n x m array, and each grid contains an integer greater than or equal to 0.
We can choose to draw a vertical line or a horizontal line. In the grid where this line passes, the number in it will be reduced by one (not less than 0).
Example: If we draw a horizontal line.
So how many lines do we need at least to reduce the numbers in the grid to zero?
I have thought about using brute force search method and dynamic programming method But there is no clear proof to prove that my idea is right.
Can someone help me solve this problem? thanks.