Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
import numpy as np
x,m,n = map(int, input().split())

acq2 = 0
cost = []
skill = []
for i in range(n):
    ca = list(map(int, input().split()))
    cost.append(ca[0])
    skill.append(np.array(ca[1:]))

costmin = 0
for a in range(n):
    costmin += cost[a]

def tworaw(num):
    if (num % 2 == 0):
        return 0
    else:
        return 1

for j in range(2**n):
    buy = []
    cost_temp = 0
    skill_temp = np.zeros(m)
    acq = 1
    nn = j
    for k in range(n):
        buy.append(tworaw(nn))
        nn = nn // 2
    print(buy)


    for l in range(n):
        if (buy[l] == 1):
            cost_temp += cost[l]
            skill_temp += skill[l]
    
    for b in range(m):
        if (skill_temp[b] < x):
            acq = 0
            break
    

    if (acq == 1):
        acq2 = 1
        if (cost_temp < costmin):
            costmin = cost_temp


if (acq2 == 1):
    print(int(costmin))
else:
    print('-1')

import numpy as np
x,m,n = map(int, input().split())

acq2 = 0
cost = []
skill = []
for i in range(n):
    ca = list(map(int, input().split()))
    cost.append(ca[0])
    skill.append(np.array(ca[1:]))

costmin = 0
for a in range(n):
    costmin += cost[a]

def tworaw(num):
    if (num % 2 == 0):
        return 0
    else:
        return 1

for j in range(2**n):
    buy = []
    cost_temp = 0
    skill_temp = np.zeros(m)
    acq = 1
    nn = j
    for k in range(n):
        buy.append(tworaw(nn))
        nn = nn // 2

    for l in range(n):
        if (buy[l] == 1):
            cost_temp += cost[l]
            skill_temp += skill[l]
    
    for b in range(m):
        if (skill_temp[b] < x):
            acq = 0
            break
    

    if (acq == 1):
        acq2 = 1
        if (cost_temp < costmin):
            costmin = cost_temp


if (acq2 == 1):
    print(int(costmin))
else:
    print('-1')

import numpy as np
x,m,n = map(int, input().split())

acq2 = 0
cost = []
skill = []
for i in range(n):
    ca = list(map(int, input().split()))
    cost.append(ca[0])
    skill.append(np.array(ca[1:]))

costmin = 0
for a in range(n):
    costmin += cost[b]

def tworaw(num):
    if (num % 2 == 0):
        return 0
    else:
        return 1

for j in range(2**n):
    buy = []
    cost_temp = 0
    skill_temp = np.zeros(m)
    acq = 1
    nn = n
    for k in range(n):
        buy.append(tworaw(nn))
        nn = nn // 2
    for l in range(n):
        if (buy[l] = 1):
            cost_temp += cost[l]
            skill_temp += skill[l]
    
    for b in range(m):
        if (skill[a] < x):
            acq = 0
            break
    
    if (acq == 1):
        acq2 = 1
        if (cost_temp < costmin):
            costmin = cost_temp


if (acq2 == 1):
    print(int(costmin))
else:
    print('-1')

import numpy as np
n,m,x = map(int, input().split())

acq2 = 0
cost = []
skill = []
for i in range(n):
    ca = list(map(int, input().split()))
    cost.append(ca[0])
    skill.append(np.array(ca[1:]))

costmin = 0
for a in range(n):
    costmin += cost[a]

def tworaw(num):
    if (num % 2 == 0):
        return 0
    else:
        return 1

for j in range(2**n):
    buy = []
    cost_temp = 0
    skill_temp = np.zeros(m)
    acq = 1
    nn = j
    for k in range(n):
        buy.append(tworaw(nn))
        nn = nn // 2

    for l in range(n):
        if (buy[l] == 1):
            cost_temp += cost[l]
            skill_temp += skill[l]
    
    for b in range(m):
        if (skill_temp[b] < x):
            acq = 0
            break
    

    if (acq == 1):
        acq2 = 1
        if (cost_temp < costmin):
            costmin = cost_temp


if (acq2 == 1):
    print(int(costmin))
else:
    print('-1')

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted