I have been trying to understand the logic behind this problem for a lot of days but couldn't get any near the answer. I would appreciate some help. asked 11 Jan, 14:16

From INOI 2018 Discussion , "For second one, The observation was that, we can take one path and calculate the total sum without a second path using dp[i][j][k] = min/max(dp[i1][j][k], dp[i1][j1][k1])+prefix_sum[i][j]. We calculate this two times, once for min and once for max and then we can use the prefix sum intuition to subtract mindp from maxdp. It's not clear enough here, but you might get an essence." answered 11 Jan, 18:23
