I am trying to solve the SPOJ Problem Martian Mining link text

but not able to think how to use Dynamic Programming here.

Please help me how to appply DP in this problem.

I am trying to solve the SPOJ Problem Martian Mining link text

but not able to think how to use Dynamic Programming here.

Please help me how to appply DP in this problem.

I’ll try not to give too much away.

Why are the following true?

- Every square should be mined (have some conveyor belt to a refinery)
- The length of conveyor belts will have an ordering

Focus on one direction (rows or columns) and play with small cases. Try n = 1 or 2.

Goodluck!