you give row x cols matrix grid represent field cherry gridij represent number cherry collect j cellyou robot collect cherry yourobot 1 locate topleft corner 0 0 androbot 2 locate topright corner 0 col 1return maximum number cherry collection robot follow rule belowfrom cell j robot cell 1 j 1 1 j 1 j 1when robot pass cell it pick cherry cell cellWhen robot stay cell take cherriesboth robot outside grid momentboth robot reach row grid Example 1input grid 311251155211output 24explanation Path robot 1 2 describe color green blue respectivelycherrie take Robot 1 3 2 5 2 12cherrie take Robot 2 1 5 5 1 12total cherry 12 12 24example 2input grid 10000012000030209000003054001023006output 28explanation Path robot 1 2 describe color green blue respectivelycherrie take Robot 1 1 9 5 2 17cherrie take Robot 2 1 3 4 3 11total cherry 17 11 28 Constraintsrows gridlengthcol gridilength2 row col 700 gridij 100