Python Hard
```python3 []
class Solution:
    def maxCollectedFruits(self, fruits: List[List[int]]) -> int:
        '''
        all elements in mat are <= 1000
        
        three children at (0, 0), (0, n - 1), (n - 1, 0)
        
        goal is to collect the most fruits
        
        if all children have to make n - 1 moves, then top right child always goes diagonal
        
        
        other children have two options:
        (n - 1, 0) child can go up and down one row but must turn right every move
        
        (0, n - 1) child can go left and right one col but must turn down every move
        
        probably a misworded problem
        
        prefix sums     
        dp
        
        draw
        ''' 
        N = len(fruits)
        
        total = 0
        
        i, j = 0, 0
        while i < N and j < N:
            total += fruits[i][j]
            fruits[i][j] = 0 
            i += 1
            j += 1
            
        total += fruits[N - 1][0]
        total += fruits[0][N - 1]
        fruits[N - 1][0] = 0
        fruits[0][N - 1] = 0
        
        if N == 2:
            return total
        
        
        INF = 10 ** 10
        
        
        @cache
        def calc1(i, j):
            if not (0 <= i <= N - 1):
                return -INF
            
            if j == N - 1:
                if i == N - 1:    
                    return 0
                return -INF
            
            total = fruits[i][j]
            total += max(calc1(i - 1, j + 1), calc1(i, j + 1), calc1(i + 1, j + 1))
            return total
            
            
        @cache
        def calc2(i, j):
            if not (0 <= j <= N - 1):
                return -INF
            
            if i == N - 1:
                if j == N - 1:
                    return 0
                return -INF
            
  
            total = fruits[i][j]
            
            total += max(calc2(i + 1, j - 1), calc2(i + 1, j), calc2(i + 1, j + 1))
            return total
            
            
        
        
        total += calc1(N - 1, 0)
        total += calc2(0, N - 1)
        
        return total
            
        
        
        
        
```
['Python3']