def find_sol(c, ws, vs, memo):
    """
    Finds an optimal solution for the given instance of the knapsack problem
    with weight capacity c, item weights ws, and item values vs, provided
    maximum total value for subproblems are memoized in memo.
    """
    sol = []
    for n in reversed(range(len(ws))):
        if c >= ws[n] and memo[n][c] == vs[n] + memo[n - 1][c - ws[n]]:
            sol.append(n)
            c -= ws[n]
    return sol