import math


def knapsack(items: list[tuple[float, float]], n: int, cap: float) -> float:
    if (cap < 0):
        return -math.inf
    if (n == len(items)):
        return 0

    return max(
        knapsack(items, n + 1, cap),
        items[n][0] + knapsack(items, n + 1, cap - items[n][1])
    )


if __name__ == '__main__':
    print(knapsack([(100, 10), (70, 4), (50, 6), (10, 12)], 0, 12))
