def _top_down_cut_rod_recursive(n: int, prices: list, max_rev: list):
    """
    Constructs a top-down dynamic programming solution for the rod-cutting problem
    via memoization.

    Runtime: O(n^2)

    Arguments
    --------
    n: int, the length of the rod
    prices: list, the prices for each piece of rod. ``p[i-i]`` is the
    price for a rod of length ``i``
    max_rev: list, the computed maximum revenue for a piece of rod.
    ``max_rev[i]`` is the maximum revenue obtainable for a rod of length ``i``

    Returns
    -------
    The maximum revenue obtainable for a rod of length n given the list of prices
    for each piece.
    """
    if max_rev[n] >= 0:
        return max_rev[n]
    elif n == 0:
        return 0
    else:
        max_revenue = float("-inf")
        for i in range(1, n + 1):
            max_revenue = max(
                max_revenue,
                prices[i - 1] + _top_down_cut_rod_recursive(n - i, prices, max_rev),
            )

        max_rev[n] = max_revenue

    return max_rev[n]