def top_down_cut_rod(n: int, prices: list):
    "\n    Constructs a top-down dynamic programming solution for the rod-cutting\n    problem via memoization. This function serves as a wrapper for\n    _top_down_cut_rod_recursive\n\n    Runtime: O(n^2)\n\n    Arguments\n    --------\n    n: int, the length of the rod\n    prices: list, the prices for each piece of rod. ``p[i-i]`` is the\n    price for a rod of length ``i``\n\n    Note\n    ----\n    For convenience and because Python's lists using 0-indexing, length(max_rev) =\n    n + 1, to accommodate for the revenue obtainable from a rod of length 0.\n\n    Returns\n    -------\n    The maximum revenue obtainable for a rod of length n given the list of prices\n    for each piece.\n\n    Examples\n    -------\n    >>> top_down_cut_rod(4, [1, 5, 8, 9])\n    10\n    >>> top_down_cut_rod(10, [1, 5, 8, 9, 10, 17, 17, 20, 24, 30])\n    30\n    "
    _enforce_args(n, prices)
    max_rev = [float('-inf') for _ in range((n + 1))]
    return _top_down_cut_rod_recursive(n, prices, max_rev)
Constructs a top-down dynamic programming solution for the rod-cutting
problem via memoization. This function serves as a wrapper for
_top_down_cut_rod_recursive

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``

Note
----
For convenience and because Python's lists using 0-indexing, length(max_rev) =
n + 1, to accommodate for the revenue obtainable from a rod of length 0.

Returns
-------
The maximum revenue obtainable for a rod of length n given the list of prices
for each piece.

Examples
-------
>>> top_down_cut_rod(4, [1, 5, 8, 9])
10
>>> top_down_cut_rod(10, [1, 5, 8, 9, 10, 17, 17, 20, 24, 30])
30
def top_down_cut_rod(n: int, prices: list):
    "\n    Constructs a top-down dynamic programming solution for the rod-cutting\n    problem via memoization. This function serves as a wrapper for\n    _top_down_cut_rod_recursive\n\n    Runtime: O(n^2)\n\n    Arguments\n    --------\n    n: int, the length of the rod\n    prices: list, the prices for each piece of rod. ``p[i-i]`` is the\n    price for a rod of length ``i``\n\n    Note\n    ----\n    For convenience and because Python's lists using 0-indexing, length(max_rev) =\n    n + 1, to accommodate for the revenue obtainable from a rod of length 0.\n\n    Returns\n    -------\n    The maximum revenue obtainable for a rod of length n given the list of prices\n    for each piece.\n\n    Examples\n    -------\n    >>> top_down_cut_rod(4, [1, 5, 8, 9])\n    10\n    >>> top_down_cut_rod(10, [1, 5, 8, 9, 10, 17, 17, 20, 24, 30])\n    30\n    "
    _enforce_args(n, prices)
    max_rev = [float('-inf') for _ in range((n + 1))]
    return _top_down_cut_rod_recursive(n, prices, max_rev)