def _fill_table(n: int, I: list, w: list, v: list, K: int) -> list:
    """
        Fill table for dynamic algorithm.

        Parameters:
        -----------
        - n : number of items
        - I : items
        - w : items' weights
        - v : items' value
        - K : knapsack size

        Result:
        -------
        filled_table : table of size K+1 x |I|+1
    """
    rows = range(K + 1)

    filled_table = [[0 for _ in range(n + 1)] for _ in rows]

    for item in I:
        weight = w[item]
        value = v[item]

        for row in rows:
            if weight > row:
                filled_table[row][item] = filled_table[row][item - 1]
            else:
                filled_table[row][item] = max(
                    filled_table[row][item - 1],
                    filled_table[row - weight][item - 1] + value
                )

    return filled_table