def morral(bagSize, pesos, valores, n):
    if n == 0 or bagSize == 0:
        return 0
    
    if pesos[n -1] > bagSize:
        return morral(bagSize, pesos, valores, n-1)
    return max(valores[n-1] + morral(bagSize - pesos[n-1], pesos, valores, n-1), morral(bagSize, pesos, valores, n-1))


if __name__ == "__main__":
    valores = [100, 200, 700]
    pesos = [10,20, 30]
    tamanoMorral = 50
    n = len(valores)

    result = morral(tamanoMorral, pesos, valores, n)
    print(result)
def morral(bagSize, pesos, valores, n):
    if n == 0 or bagSize == 0:
        return 0
    
    if pesos[n -1] > bagSize:
        return morral(bagSize, pesos, valores, n-1)
    return max(valores[n-1] + morral(bagSize - pesos[n-1], pesos, valores, n-1), morral(bagSize, pesos, valores, n-1))


if __name__ == "__main__":
    valores = [100, 200, 700]
    pesos = [10,20, 30]
    tamanoMorral = 50
    n = len(valores)

    result = morral(tamanoMorral, pesos, valores, n)
    print(result)