Problem:


Score : 300 points

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.

Constraints

All values in input are integers.

1\leq N, M\leq 12

1\leq X\leq 10^5

1\leq C_i \leq 10^5

0\leq A_{i, j} \leq 10^5

Input

Input is given from Standard Input in the following format:

N M X
C_1 A_{1,1} A_{1,2} \cdots A_{1,M}
C_2 A_{2,1} A_{2,2} \cdots A_{2,M}
\vdots
C_N A_{N,1} A_{N,2} \cdots A_{N,M}

Output

If the objective is not achievable, print -1; otherwise, print the minimum amount of money needed to achieve it.

Sample Input 1

3 3 10
60 2 2 4
70 8 7 9
50 2 3 9

Sample Output 1

120

Buying the second and third books makes his understanding levels of all the algorithms 10 or higher, at the minimum cost possible.

Sample Input 2

3 3 10
100 3 1 4
100 1 5 9
100 2 6 5

Sample Output 2

-1

Buying all the books is still not enough to make his understanding levels of all the algorithms 10 or higher.

Sample Input 3

8 5 22
100 3 7 5 3 1
164 4 5 2 7 8
334 7 2 7 2 9
234 4 7 2 8 2
541 5 4 3 3 6
235 4 8 6 9 7
394 3 6 1 6 2
872 8 4 3 7 2

Sample Output 3

1067



Sample input:
3 3 10
60 2 2 4
70 8 7 9
50 2 3 9


Sample output:
120

Submission status: Runtime Error

Solution code:
n,m,x = map(int,input().split())
costlst = []
scorelst = []
ans = float("inf")
for _ in range(m):
    cost,*score = map(int,input().split())
    costlst.append(cost)
    scorelst.append(score)
for i in range(2**n):
    cost = 0
    defaultscore = [0]*m
    for j in range(n):
        if (i>>j)&1:
            cost += costlst[j]
            for k in range(m):
                defaultscore[k] += scorelst[j][k]
        if all([defaultscore[p] >= x for p in range(m)]):
            ans = min(ans,cost)
        
            
                
                
                 
print(ans if ans != float("inf") else "-1")

Submission status: Runtime Error

Solution code:
import numpy as np
INF = pow(10, 9)


def main():
    n, m, x = map(int, input().split())
    i = 0
    c = []
    a = []

    for i in range(n):
        tmp = list(map(int, input().split()))
        c.append(tmp[0])
        a.append(tmp[1:])

    ans = INF
    for i in range(2**n):
        tmp = np.array([0 for i in range(m)])
        cost = 0
        flag = True
        for j in range(n):
            if ((i >> j) & 1) == 1:
                tmp += a[j]
                cost += c[j]
        # print(tmp)
        for j in range(m):
            if tmp[j] < x:
                flag = False
                break
        # print(cost)
        if flag == True:
            if cost < ans:
                ans = cost
    print(ans) if ans != INF else print(-1)

    return


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from itertools import combinations

n,m,x = map(int,input().split())
input_list = []
for i in range(n):
    input_list.append(list(map(int,input().split())))
    
result_list = []
for k in range(n):
    for i in combinations(input_list,k+1):
        count_1 = 0
        count_2 = 0
        count_3 = 0
        count_4 = 0
        for j in range(k+1):
            count_1 += i[j][0]
            count_2 += i[j][1]
            count_3 += i[j][2]
            count_4 += i[j][3]

        if count_2 >= x and count_3 >= x and count_4 >= x:
            result_list.append(count_1)
            
if len(result_list) == 0:
    print('-1')
else:
    print(min(result_list))

Submission status: Runtime Error

Solution code:
n,m,x = map(int,input().split())
input_list = []
for i in range(n):
    input_list.append(list(map(int,input().split())))
    
result_list = []
for k in range(n):
    for i in combinations(input_list,k+1):
        count_1 = 0
        count_2 = 0
        count_3 = 0
        count_4 = 0
        for j in range(k+1):
            count_1 += i[j][0]
            count_2 += i[j][1]
            count_3 += i[j][2]
            count_4 += i[j][3]

        if count_2 >= x and count_3 >= x and count_4 >= x:
            result_list.append(count_1)
            
if len(result_list) == 0:
    print('-1')
else:
    print(min(result_list))

Submission status: Runtime Error

Solution code:
n, m, x = map(int, input().split())
numlist = []
minimum = -1
for i in range(n):
    numlist.append(list(map(int, input().split())))
for i in range(1<<n):
    result = [0] * (m+1)
    for j in range(n):
        if(i>>j & 1 == 1):
            for k in range(m+1):
                result[k] += numlist[j][k]
    for k in range(m):
        if(result[k+1] < x): break
    else:
        if(min > result[0] or minimum == -1): minimum = result[0]
print(minimum)

Submission status: Runtime Error

Solution code:
import numpy as np

n,m,x = (int(x) for x in input().split())

goal = [ list(map(int,input().split(" "))) for i in range(n)]
okane = 10 ** 5 + 1
sum = []
#print(goal)

for j in range(2 ** n):
    ll = []
    ls = ["+"] * n
    result = []
    for k in range(len(ls)):
        if (j >> k) & 1:
            ls[k] = "-"

    #print(ls)    
    #print(ll)

    for h in range(n):
        
        #print(ls[h])
        if ls[h] == "+":
            ll.append(goal[h])
    #print(ll)


    result = np.sum(ll,axis=0,keepdims=True)
    #print(result)

    if len(ll) > 0:
        hantei = True
        for i in range(2):
            if result[0][i+1] < x :
                hantei = False

        if hantei == True and okane > result[0][0]:
            okane = result[0][0]     

if okane == 10 ** 5 + 1:
    print(-1)
else:
    print(okane)

Submission status: Runtime Error

Solution code:
import numpy as np

n,m,x = (int(x) for x in input().split())

goal = [ list(map(int,input().split(" "))) for i in range(n)]
okane = 10 ** 5
sum = []
#print(goal)

for j in range(2 ** n):
    ll = []
    ls = ["+"] * n
    result = []
    for k in range(len(ls)):
        if (j >> k) & 1:
            ls[k] = "-"

    #print(ls)    
    #print(ll)

    for h in range(n):
        
        #print(ls[h])
        if ls[h] == "+":
            ll.append(goal[h])
    #print(ll)


    result = np.sum(ll,axis=0,keepdims=True)
    #print(result)

    if len(ll) > 0:
        hantei = True
        for i in range(2):
            if result[0][i+1] < x :
                hantei = False

        if hantei == True and okane > result[0][0]:
            okane = result[0][0]     

if okane == 10 ** 5:
    print(-1)
else:
    print(okane)

Submission status: Runtime Error

Solution code:
n, m, x = map(int, input().split())
keep = []
ans = 10**10
for i in range(n):
    c = list(map(int, input().split()))
    keep.append(c)

for j in range(2**n):
    bag = [0] * n
    total = 0
    check = 1
    for k in range(n):
        if ((j >> k) & 1):
            for l in range(m):
                bag[l] += keep[k][l + 1]
            total += keep[k][0]
    for a in range(m):
        if bag[a] < x:
            check *= 0
    if ans * check > total:
        ans = total
if ans == 10**10:
    print(-1)
else:
    print(ans)

Submission status: Runtime Error

Solution code:
n, m, x = list(map(int, input().split()))
c = []
a = []

for i in range(n):
    tmp = list(map(int, input().split()))
    c.append(tmp[0])
    a.append([])
    
    for j in range(m):
        a[i].append(tmp[j])

ab = []
for i in range(m):
    sum = 0
    for j in range(n):
        sum += a[j][i]
    ab.append(bool(sum > x))

print(all[ab])

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline


def main():
    n, m, x = map(int, input().split())

    MONEY = []
    UNDERSTAND = []
    for i in range(n):
        lst = [int(i) for i in input().split()]
        MONEY.append(lst[0])
        UNDERSTAND.append(lst[1:])

    ans = []
    for i in range(1 << n):
        understand = [0] * m
        money = 0
        for j in range(n):
            if (i >> j) & 1 == 0:
                continue
            money += MONEY[j]
            for k in range(m):
                understand[k] += UNDERSTAND[j][k]
        if all([i >= x for i in understand]):
            ans.append(money)

    print(min(ans))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readlinedef


def main():
    n, m, x = map(int, input().split())

    MONEY = []
    UNDERSTAND = []
    for i in range(n):
        lst = [int(i) for i in input().split()]
        MONEY.append(lst[0])
        UNDERSTAND.append(lst[1:])

    ans = []
    for i in range(1 << n):
        understand = [0] * m
        money = 0
        for j in range(n):
            if (i >> j) & 1 == 0:
                continue
            money += MONEY[j]
            for k in range(m):
                understand[k] += UNDERSTAND[j][k]
        if all([i >= x for i in understand]):
            ans.append(money)

    print(min(ans))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline


def main():
    n, m, x = map(int, input().split())
    lst = [[int(i) for i in input().split()] for _ in range(n)]

    ans = []
    for i in range(1 << n):
        understand = []
        money = 0
        for j in range(n):
            if (i >> j) & 1 == 0:
                continue
            money += lst[0]
            for k in range(m):
                understand[k] += lst[k + 1]
        if all([i >= x for i in understand]):
            ans.append(money)

    print(min(ans))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n,m,x = map(int, input().split())
result = 10**9
for _ in range(n):
	books=list(map(int, input().split()))
	A = A.append(books[0])
	C = C.append(books[1:])
for i in range(1<<n):
	cnt = 0
	rikaido = [0]*m
	for j in range(n):
		if (i<<j)&1:
			for k in range(m):
				rikaido[k]+=C[j][k]
			cnt += A[j]
		else:
			pass
	if min(rikaido)>=x:
		result = min(result, cnt)
if result == 10*9:
	print(-1)
else:
	print(result)

Submission status: Runtime Error

Solution code:
n,m,X = map(int,input().split())

C=[]
A=[]
for i in range(n):
	t = list(map(int, input().split()))
	C.append(t[0])#price of books
	A.append(t[1:])#point of books
	
result = -1 #結果の初期値
#N冊の本買う/買わない　を総当たり
for i in range(1<<n):#range(0,2**n)と同意
	t = [0] * m #理解度m個
	c = 0 #値段0
	#1-n冊目までをシフト演算
	for j in range(n):
		if (i>>j)&1:#購入している場合
			for k in range(m):
				t[k] += A[j][k]#各理解度をインプット
			c += C[j] #購入した本の値段を足していく
		else:
			pass
	if min(t)>=x:
		result==min(result, t)
if result == 10**9:
	print(-1)
else:
	print(result)

Submission status: Runtime Error

Solution code:
n,m,x=map(int,input().split())
nedan=[]
grade=[]
inf=12*10**6
for i in range(n):
  s=list(map(int,input().split())) 
  nedan.append(s.pop(0))
  grade.append(s)
#print(nedan)
#print(grade)

for i in range(2**n):
  shopping=[]
  total_grade=[]
  for j in range(n):
    if (( i >> j ) & 1):
      shopping.append(nedan[j])
      total_grade.append(grade[j])

  t=sum(shopping)
  #print(t)
  #print(shopping)
  #print(total_grade)
  sum_grade=[]
  for j in range(m):
    s=0
    for k in range(len(total_grade)):
        s+=total_grade[k][j]
    sum_grade.append(s)
    print(sum_grade)

  ans_t=[]
  if all(j>=x for j in sum_grade):
    ans_t.append(t)

print(ans_t)   
ans=min(ans_t)

if min(ans,inf)==ans:
  print(ans)

else:
  print(-1)

Submission status: Runtime Error

Solution code:
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')

Submission status: Runtime Error

Solution code:
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')

Submission status: Runtime Error

Solution code:
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')

Submission status: Runtime Error

Solution code:
n,m,x = map(input().split())

min_money = 999999999999
for i in range(2**n):
	bag = []
	a = list(map(int,input().split()))
	for j in range(n):
		if ((i >> j) & 1):
			bag.append(a)

	money = 0
	skill = [0] * m
	enogh = [0] * m
	for sub in bag:
		money += sub[0]
		for k in range(1,m+1):
			skill[k-1] += sub[k]
			if skill[k-1] >= x:
				enough[k-1] = 1

	if 0 not in enough and min_money > money:
		min_money = money

if min_money != 999999999999:
	print(min_money)
else:
	print(-1)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!

n,m,k = map(int,input().split())
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。
x=[[0] * m for i in range(2**n)] 
#print(listA)
for i in range(2 ** n):
    for j in range(n):
        if((i >> j) & 1 ):
            x[i][0] += listA[j][0]
            x[i][1] += listA[j][1]
            x[i][2] += listA[j][2]
#print(x)

cnt = 10**9
t = [k] * m
for i in x:
    u = 0
    for j in range(1, m-1):
        if i[j] < t[j]:
            u = 1
        if u != 1:
            if cnt >= i[0]:
                cnt = i[0]
    #print(cnt)    
if cnt != 10**9:
    print(cnt)
else:
    print(-1)

Submission status: Runtime Error

Solution code:
import numpy as np 
from itertools import combinations

n,m,x = map(int, input().split())
n_num = [_ for _ in range(n)]

l = np.array([list(map(int, input().split())) for _ in range(n)])

ptns = []
for i in range(n):
    ptns += list(combinations(n_num, i+1))

ans = float('inf')
for j in range(len(ptns)):
    tmp = np.array([0]*(m+1))
    for k in range(len(ptns[j])):
        tmp += l[ptns[j][k]]
    if min(tmp[1:-1]) >= x:
        ans = min(ans, tmp[0])
    
print(-1 if ans == float('inf') else ans)

Submission status: Runtime Error

Solution code:
n, m, x = map(int,input().split())

a = [[0 for i in range(m)] for _ in range(n)]
c = [0] * n
for sankousyo in range(n):
    c_and_a = list(map(int,input().split()))
    c[sankousyo] = c_and_a[0]
    a[sankousyo] = c_and_a[1:]
    
cost = [0] * (2**n)
INF = 10**12
res_cost = INF
for i in range(2**n):
    understandings = [0] * m
    cost_sum = 0
    for j in range(n):
        if (i >> j) & 1:

            cost_sum += c[j]
            
            for k in range(m):
                understandings[k] = understandings[k] + a[j][k]

    res = True
    for j in range(n):
        if understandings[j] < x:
            res = False 

    if res:
        if res_cost > cost_sum:
            res_cost = cost_sum

if res_cost == INF:
    print(-1)
else:
    print(f"お会計は{res_cost}円です")

Submission status: Runtime Error

Solution code:
n,m,x = map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(n)]
c = [ca[i][0] for i in range(n)]
a = [ca[i][1:] for i in range(n)]

price = sum(c)
l =0

for i in range(2**m):
    kari = 0
    skill = [0]*m
    for j in range(m):
        if (i>>j) & 1:
            skill = [x + y for(x,y) in zip(skill,a[j]) ]
            kari += c[j]
    if all([z >= x for z in skill]):
        price = min(price, kari)
        l += 1

if l == 0:
    print(-1)
else:
    print(price)

Submission status: Runtime Error

Solution code:
n,m,x=map(int,input().split())
a=[]
ans=-1
t=[0]*(m+1)
for i in range(n):
    a.append(list(map(int,input().split())))
for i in range(2 ** n):
    for j in range(n):
        if (i >> j) & 1:
            for lnd,l in enumerate(a[j]):
                t[lnd]+=l
    if ans==-1 or ans > t[0]:
        if min(t[1:m]) >= x:
            ans = t[0]
    t=[0]*(m+1)
print(ans)

Submission status: Runtime Error

Solution code:
def cos_per_find(count, cost, skills):
    if count == N:
        if min(skills) >= X:
            return cost
        else:
            return INF
    improved_skills = [a+b for a, b in zip(skills, contents[count])]
    return min(cos_per_find(count+1, cost, skills), cos_per_find(count+1, cost+price[count], improved_skills))

INF = float(inf)
N, M, X = map(int, input().split())
price = []
contents = []
for i in range(N):
    C, *A = map(int, input().split())
    price.append(C)
    contents.append(A)
ans = cos_per_find(0, 0, [0]*M)
if ans == INF:
    print(-1)
else:
    print(ans)

Submission status: Runtime Error

Solution code:
def cos_per_find(count, cost, skills):
    if count == N:
        if min(skills) >= X:
            return cost
        else:
            return INF
    improved_skills = [a+b for a, b in zip(skills, contents[count])]
    return min(cos_per_find(count+1, cost, skills), cos_per_find(count+1, cost+price[count], improved_skills))

INF = float(inf)
N, M, X = map(int, input().split())
price = []
contents = []
for i in range(N):
    C, *A = map(int, input().split())
    price.append(C)
    contents.append(A)
if (ans := cos_per_find(0, 0, [0]*M)) == INF:
    print(-1)
else:
    print(ans)

Submission status: Runtime Error

Solution code:
N,M,X=map(int,input().split())
ca =[list(map(int,input().split())) for i in range(N)]
ans=float('inf')
for i in range(1,2**N):
  rikaido=[0]*M
  money=0
  for j in range(N):
    if i>>j&1:
      money +=ca[j][0]
      for k in range(1,M+1):
      rikaido[k-1] += ca[j][k]
    for l in range(M):
      if all(rikaido[l] >= X for l in range(M)):
        ans=min(money,ans)
if ans==float('inf'):
  print(-1)
else:
  print(ans)

Submission status: Runtime Error

Solution code:
def cos_per_find(count, cost, skills):
    if count == N:
        if min(skills) >= X:
            return cost
        else:
            return INF
    improved_skills = [a+b for a, b in zip(skills, contents[count])]
    return min(cos_per_find(count+1, cost, skills), cos_per_find(count+1, cost+price[count], improved_skills))

INF = float(inf)
N, M, X = map(int, input().split())
price = []
contents = []
for i in range(N):
    C, *A = map(int, input().split())
    price.append(C)
    contents.append(A)
if ans(:=cos_per_find(0, 0, [0]*M))== INF:
    print(-1)
else:
    print(ans)

Submission status: Runtime Error

Solution code:
N,M,X = map(int,input().split(' '))
flag = 0
price = 0
for i in range(N):
  flag += i
  for j in range(M):
    temp = map(int,input().split(' '))
    temp_price = sum(temp)-i
  price += temp_price 
  if flag > X:
    print(price)
if flag<X:
  print(-1)

Submission status: Runtime Error

Solution code:
N,M,X = map(int,input().split(' '))
flag = 0
price = 0
for i in N:
  flag += i
  for j in M:
    temp = map(int,input().split(' '))
    temp_price = sum(temp)-i
  price += temp_price 
  if flag > X:
    print(price)
if flag<X:
  print(-1)

Submission status: Runtime Error

Solution code:
N,M,X = map(int,input().split(' '))
flag = 0
price = 0
for i in N:
  flag += i
  for j in M:
    temp = map(int,input().split(' '))
    temp_price = sum(temp)-i
  price += temp_price 
  if flag > X:
    print(price)
if flag<X:
  print(-1)
else

Submission status: Runtime Error

Solution code:
import itertools

f = True

N, M, X = map(int, input().split())
L = []
max = [0 for _ in range(N)]
for _ in range(N):
    i = list(map(int, input().split()))
    L.append([i[0], i[1:len(i)]])
    max = [max[j] + i[j+1] for j in range(M)]

for i in range(M):
    if not (max[i] >= X):
        f = False
        print('-1')

if f:
    res = []

    a = True

    for i in range(1, N + 1):
        P = list(itertools.combinations(L, i))

        for j in P:
            a = True

            sum = [0 for _ in range(M)]
            cost = 0
            for k in j:
                cost += k[0]
                for l in range(M):
                    sum[l] += k[1][l]

            for j in sum:
                if not (j >= X):
                    a = False
                    break

            if a:
                res.append(cost)

    print(min(res))

Submission status: Runtime Error

Solution code:
import numpy as np
N,M,X=map(int,input().split())
C=[]
A=[]
for i in range(N):
    buf=list(map(int,input().split()))
    C.append(buf[0])
    A.append(buf[1:])

MinmalCost=1e30

MaxInter=2**N-1
LenOfBin=len(bin(MaxInter)[2:])
for i in range(MaxInter+1):
    binary=bin(i)[2:].rjust(LenOfBin,"0")
    Cost=0
    Learning=np.zeros(M,)
    for j,Switch in enumerate(binary):
        if Switch=="1":
            Cost+=C[j]
            Learning+=A[j]
    if np.all(Learning>=X) and Cost<MinmalCost:
        MinmalCost=Cost
if MinmalCost==1e30:
    print(-1)
else:
    print(MinmalCost)

Submission status: Runtime Error

Solution code:
N, M = input().split()
print(N, M, X)

Submission status: Runtime Error

Solution code:
line = input()
N, M, X = [int(v) for v in line.split(" ")]

Ci, Aij = [], []
for i in range(N):
    line = input().split(" ")
    line = [int(v) for v in line]

    Ci.append(line[0])
    Aij.append(line[1:])

ans = []
def dfs(candidate):
    if len(candidate) == M:
        X_ = [0 for _ in range(M)]
        cost = 0
        for i in range(N):
            if candidate[i] == 0:
                continue
            cost += Ci[i]
            for j in range(M):
                X_[j] += Aij[i][j]
        if min(X_) >= X:
            ans.append(cost)
    else:
        for bit in range(2):
            candidate.append(bit)
            dfs(candidate)
            candidate.pop()

dfs([])
if len(ans) == 0:
    print(-1)
else:
    print(min(ans))

Submission status: Runtime Error

Solution code:
import itertools
import numpy as np

N,M,X = map(int, input().split())
lista = [list(map(int,input().split())) for i in range(N)]

lista = np.array(lista)
judge = [X]*M
cost = 1200001
data = [a for a in range(1,N+1)] # [1,2,3,...,N]

for i in range(1,N+1):
  j = list(itertools.combinations(data, i))
  for k in j:
    result = np.array([0]*(M+1))
    for l in k:
      result = result + lista[l-1]
      if all(result[1:]>=judge):
        if reslut[0]<cost:
          cost = result[0]
          m = k
c = 0

try:
  for i in m:
    c +=lista[i-1][0]
    
  print(c)
  
except:
  print(-1)

Submission status: Runtime Error

Solution code:
import itertools
import numpy as np

N,M,X = map(int, input().split())
lista = [list(map(int,input().split())) for i in range(N)]

lista = np.array(lista)
judge = [X]*M
cost = 1200001
data = [a for a in range(1,N+1)] # [1,2,3,...,N]

for i in range(1,N+1):
    j = list(itertools.combinations(data, i))
    for k in j:
        result = np.array([0]*(M+1))
        for l in k:
            result = result + lista[l-1]
        if all(result[1:]>=judge):
            if reslut[0]<cost:
                cost = result[0]
                m = k
c = 0

try:
    for i in m:
        c +=lista[i-1][0]
    
    print(c)
except:

Submission status: Runtime Error

Solution code:
(n,m,x)=map(int,input().split())
c=list()
a=list()
for i in range(n):
  line=list(map(int,input().split()))
  c.append(line.pop(0))
  a.append(line)

result=list()
for i in range(2**n):
  total=[0]*m
  cost=0
  for k in range(n):
    if bin(i)[k]=="1":
      total+=a[k]
      cost+=int(c[k])
  if total>=[x]*m:
    result.append(cost)

if result!=[]:
  print(min(result))
else:
  print(-1)

Submission status: Runtime Error

Solution code:
import itertools

N,M,X = map(int,input().split())
c = []
d = [0]*4
e = []
for _ in range(N):
  c.append(list(map(int,input().split())))
for r in range(1,N+1):
  for x in itertools.combinations(c,r):
    for y in range(len(x)):
      d[0] += x[y][0]
      d[1] += x[y][1]
      d[2] += x[y][2]
      d[3] += x[y][3]
    if d[1] < X or d[2] < X or d[3] < X:
      d = [0]*4
    else:
      e.append(d[0])
      d = [0]*4
if len(e)>0:
  print(min(e))
else:
  print(-1)

Submission status: Runtime Error

Solution code:
(n,m,x)=map(int,input().split())
c=list()
a=list()
for i in range(n):
  line=map(int,input().split())
  c.apppend(line.pop(c[0]))
  a.append(line)

for i in range(2**n):
  total=[0]*m
  cost=0
  for k in range(n):
    if int(bin(i)[k])==1:
      total+=a[k]
      cost+=c[k]
  if total>=[x]*m:
    result.append(cost)

if result!=None:
  print(min(cost))
else:
  print(-1)

Submission status: Runtime Error

Solution code:
import numpy as np

N, M, X = map(int, input().split())
C = np.zeros(N)
A = np.zeros((N, M))


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

C_MIN = 9999999999
for i in range(2 ** N):
    C_SUM = 0
    A_SUM = np.zeros(M)
    for j in range(N):
        if ((i >> j) & 1):
            C_SUM += C[j]
            A_SUM += A[j]
    if np.all(A_SUM >= X):
        if C_SUM < C_MIN:
            C_MIN = C_SUM
            
if C_MIN == 9999999999:
    print("-1")
else:
    print(C_MIN)

Submission status: Runtime Error

Solution code:
N, M, X = map(int, input().split(' '))
cost = []
A = []
for _ in range(N):
    l = list(map(int, input().split(' ')))
    cost.append(l[0])
    A.append(l[1:])
ans =10**10
prices = list()
for i in range(1,2**N+1):
    price = 0
    compre = [0 for _ in range(M)]
    for j in range(M):
        if ((i>>j)&1)==1:
            price += cost[j]
            for k in range(M):
                compre[k] += A[j][k]
            if all([m>=X for m in compre]):
                prices.append(price)
            #print(compre)
if prices != []:
    print(min(prices))
else:
    print(-1)

Submission status: Runtime Error

Solution code:
import numpy as np
from numpy import array


n, m, x = list(map(int, input().split()))
a = []
for i in range(n):
    a.append(list(map(int, input().split())))

a = array(a)

c_min = 1e5 * n
flag = False

for i in range(1, n ** 2 + 1):
    j = str(bin(i))

    b = np.zeros(m+1)

    for k in range(n):
        if j[k] == 1:
            b += a[k]
    
    if np.all(b[1:] >= m):
        c_min = min(c_min, b[0])
        flag = True

if flag == False:
    c_min = -1

print(c_min)

Submission status: Runtime Error

Solution code:
def test():
    n, m, x = map(int, input().split())
    books = [list(map(int, input().split())) for _ in range(n)]
    ans = 99999999999999999
    for i in range(2 ** n):
        cost = 0
        level = [0] * (m)
        for j in range(n):
            if ((i >> j) & 1):
                cost += books[j][0]
                for k in range(m):
                    level[k] += books[j][k+1]

        if level and min(*level) >= x:
            ans = min(ans, cost)

    if ans == 99999999999999999:
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    test()

Submission status: Runtime Error

Solution code:
import sys


def test():
    n, m, x = map(int, input().split())
    books = [list(map(int, input().split())) for _ in range(n)]
    ans = 12345678
    is_ok = False
    for i in range(2 ** n):
        cost = 0
        level = [0] * (m)
        for j in range(n):
            if ((i >> j) & 1):
                cost += books[j][0]
                for k in range(m):
                    level[k] += books[j][k+1]

        if min(*level) >= x:
            ans = min(ans, cost)
            is_ok = True

    if is_ok:
        print(ans)
    else:
        print(-1)


if __name__ == "__main__":
    test()

Submission status: Runtime Error

Solution code:
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M,X = map(int, readline().split())
data = np.array(read().split(), np.int64)
data = data.reshape(N,-1)
C = data[:,0]
A = data[:,1:]

cost = np.zeros(1<<N, np.int64)
dability = np.zeros((1<<N, M), np.int64)

for i in range(N):
  cost[1<<i:1<<(i+1)] = cost[:1<<i] + C[i]
  ability[1<<i:1<<(i+1)] = ability[:1<<i] + A[i]
  
ok = np.all(ability >= X, axis=1)

x = cost[ok]
answer = -1 if len(x) == 0 else x.min()
print(answer)

Submission status: Runtime Error

Solution code:
import itertools

N, M, X = map(int, input().split())
C = []
for i in range(N):
    C.append(list(map(int, input().split())))
ans = 10**6

for i in range(1, N+1):
    for j in itertools.permutations(C, i):
        a, b, c = 0, 0, 0
        cost = 0
        for k in j:
            a += k[1]
            b += k[2]
            c += k[3]
            cost += k[0]
        if X <= a and X <= b and X <= c:
            ans = min(ans, cost)
if ans == 10**6:
    print(-1)
else:
    print(ans)

Submission status: Runtime Error

Solution code:
N,M,X = map(int,input().split())

A =  []
S = [0 for _ in range(N)] 
min_value = 0 
score=[0 for _ in range(N)] 

for x in range(N):
  A.append(list(map(int,input().split())))

for x in range(N):
  min_value += A[x][0]
  
sucess = 0

for bit in range(2**N):
  for i in range(N):
    if (bit >> i) & 1:
      S.append(A[i][0])
      for x in range(M):
        score[x] += A[i][x+1]
  flag = 0

  for k in score:
    if k >= 10:
      flag += 1
    if flag ==len(score):
      if min_value >= sum(S):
        min_value = sum(S)
        sucess += 1 
        
  score=[0 for _ in range(N)]
  S =[]
  
if sucess > 0:
	print(min_value)
else:
  print("-1")