I try this problem on spoj but I get TLE. Someone can help me?
We have a m*n matrix of integer [0,2] and John are currently at the upper left position (row 1, column 1) and he want to come row m column n. He can travel right, left, toward the top, or toward the bottom of the grid. He can not travel on a diagonal. But John only love 0 and 1 so that he decide to chose the path which only have 0,1 and he want to his path is maximum value in decimal. John need your help!
Line 1: contain two integer m,n.
Line 2..m+1: Each line contains n integers.
The path which is maximum in decimal
(The input certain that John can come to row m column n)
0 1 2 0 2
0 1 0 0 1
1 2 1 2 1
You can sumbit solution here