Check if we can cut vertically at c1 , at least one apple in matrix ( r , c ) -> R - 1 , c1
if preSum [ r ] - preSum [ r ] [ c1 ] > 0 : NEW_LINE INDENT dp [ k ] [ r ] += dp [ k - 1 ] [ r ] [ c1 ] NEW_LINE DEDENT return dp [ K ] [ 0 ] [ 0 ] NEW_LINE