Problem p02683 (python)

Fixed submission:
N, M, X = map(int, input().split())

A = [[] for i in range(N)]
C = [0] * N
for i in range(N):
    c_as = list(map(int, input().split()))
    C[i], A[i] = c_as[0], c_as[1:]

INF = 10**9
ans = INF
for s in range(0, 1 << N):
    smart = [0] * M
    cost_sum = 0
    for i in range(N):
        if (s >> i) % 2 == 0:
            continue
        cost_sum += C[i]
        for j in range(M):
            smart[j] += A[i][j]
    ok = True
    for j in range(M):
        if smart[j] < X:
            ok = False
    if ok:
        ans = min(ans, cost_sum)
if ans == INF:
    ans = -1
print(ans)

Buggy submission (verdict: Runtime Error):
N, M, X = map(int, input().split())

A = [[] for i in range(N)]
c = [0] * N
for i in range(N):
    c_as = list(map(int, input().split()))
    c[i], A[i] = c_as[0], c_as[1:]

INF = 10**9
ans = INF
for s in range(0, 1 << N):
    smart = [0] * M
    cost_sum = 0
    for i in range(N):
        if (s >> i) % 2 == 0:continue
        cost_sum += c[i]
        for j in range(M):
            smart[j] += A[i][j]
    ok = True
    for i in range(N):
        if smart[i] < X:
            ok = False
    if ok:
        ans = min(ans, cost_sum)

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import copy
N, M, X = map(int, input().split())
C = np.zeros(N, dtype=np.uint16)
A = np.zeros([N, M], dtype=np.uint16)
skills = np.zeros(M, dtype=np.uint16)
sum_skills = np.zeros(M, dtype=np.uint32)
sum_A = np.zeros(N, dtype=np.uint32)

for n in range(N):
    CA = list(map(np.uint16, input().split()))
    C[n] = CA[0]
    A[n] = CA[1:]
    sum_skills += CA[1:]
    sum_A[n] = sum(CA[1:])


def check_skills(skills):
    return np.all(skills >= X)


if np.all(sum_skills >= X):
    pass
else:
    print("-1")
    exit()

results = []
book_sorted = np.argsort(sum_A)
for n in range(M):
    result = ([n], C[n].copy(), A[n].copy())
    results.append(result)

min_cost = np.sum(C)

while len(results) > 0:
    result = results.pop(0)
    if check_skills(result[2]):
        min_cost = min(min_cost, result[1])
    elif result[1] > min_cost:
        continue
    else:
        max_idx = max(result[0])
        for idx in range(max_idx+1, N):
            (idxes, total_cost, skill_values) = copy.copy(result)
            idxes = idxes + [idx]
            total_cost = total_cost + C[idx]
            skill_values = skill_values + A[idx]
            results.append((idxes, total_cost, skill_values))

print(min_cost)

Buggy submission (verdict: Runtime Error):
import numpy as np
import copy
N, M, X = map(int, input().split())
C = np.zeros(N, dtype=np.uint16)
A = np.zeros([N, M], dtype=np.unt16)
skills = np.zeros(M, dtype=np.uint16)
sum_skills = np.zeros(M, dtype=np.uint32)
sum_A = np.zeros(N, dtype=np.uint32)

for n in range(N):
    CA = list(map(int, input().split()))
    C[n] = CA[0]
    A[n] = CA[1:]
    sum_skills += CA[1:]
    sum_A[n] = sum(CA[1:])


def check_skills(skills):
    return np.all(skills >= X)


if np.all(sum_skills >= X):
    pass
else:
    print("-1")
    exit()

results = []
book_sorted = np.argsort(sum_A)
for n in range(M):
    result = ([n], C[n].copy(), A[n].copy())
    results.append(result)

min_cost = np.sum(C)

while len(results) > 0:
    result = results.pop(0)
    if check_skills(result[2]):
        min_cost = min(min_cost, result[1])
    elif result[1] > min_cost:
        continue
    else:
        max_idx = max(result[0])
        for idx in range(max_idx+1, N):
            (idxes, total_cost, skill_values) = copy.copy(result)
            idxes = idxes + [idx]
            total_cost = total_cost + C[idx]
            skill_values = skill_values + A[idx]
            results.append((idxes, total_cost, skill_values))

print(min_cost)

Buggy submission (verdict: Runtime Error):
import numpy as np
import copy
N, M, X = map(int, input().split())
C = np.zeros(N, dtype=np.int64)
A = np.zeros([N, M], dtype=np.int64)
skills = np.zeros(M, dtype=np.int64)
sum_skills = np.zeros(M, dtype=np.int64)
sum_A = np.zeros(N, dtype=np.int64)

for n in range(N):
    CA = list(map(int, input().split()))
    C[n] = CA[0]
    A[n] = CA[1:]
    sum_skills += CA[1:]
    sum_A[n] = sum(CA[1:])


def check_skills(skills):
    return np.all(skills >= X)


if np.all(sum_skills >= X):
    pass
else:
    print("-1")
    exit()

results = []
book_sorted = np.argsort(sum_A)
for n in range(M):
    result = ([n], C[n].copy(), A[n].copy())
    results.append(result)

min_cost = np.sum(C)

while len(results) > 0:
    result = results.pop(0)
    if check_skills(result[2]):
        min_cost = min(min_cost, result[1])
    else:
        max_idx = max(result[0])
        for idx in range(max_idx+1, N):
            (idxes, total_cost, skill_values) = copy.copy(result)
            idxes = idxes + [idx]
            total_cost = total_cost + C[idx]
            skill_values = skill_values + A[idx]
            results.append((idxes, total_cost, skill_values))

print(min_cost)