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:
from itertools import product

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

C, A = [], []
for i in range(N):
    C.append(inp[i][0])
    A.append(inp[i][1:])

#判定
z_A = list(zip(*A))
for i in range(N):
    if sum(z_A[i]) < X:
        print(-1)
        exit()

ans = sum(C)

for buy_bit in product(range(2), repeat=N):
    buy = 0
    tmp = 0
    skill = [0] * M
    for i in range(N):
        if buy_bit[i]:
            for j in range(M):
                skill[j] += A[i][j]
            buy += C[i]
    
    f = True
    for s in skill:
        if s < X:
            f = False
            break
    if f:
        ans = min(ans, buy)

print(ans)

Submission status: Runtime Error

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

a = [[0] * m for j in range(n)]
c = [0] * n

ans = 10**10

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

# bit全探索
import itertools
for bit in itertools.product([0,1], repeat=10):
    arr = [0] * m
    cost = 0
    for i in range(n):
        if bit[i] == 1:
            for k in range(len(a[i])):
                arr[k] += a[i][k]
            cost += c[i]

    NG = False
    for i in range(len(arr)):
        if arr[i] < x:
            NG = True
            
    if NG:
        pass
    else:
        ans = min(ans,cost)

if ans != 10**10:
    print(ans)
else:
    print(-1)

Submission status: Runtime Error

Solution code:
number=list(map(int,input().split()))
n,m,x=number[0],number[1],number[2]
books=[list(map(int,input().split())) for i in range(n)]
U=[x for i in range(m+1)]
U[0]=0
pattern=[]
answer=[]


for i in range(2**n):
    tmp=[False]*n
    for j in range(n):
        if (i>>j)&1:
            tmp[j]=True
    
    pattern.append(tmp)

for i in range(2**n):
    cost=0
    U=[x for i in range(m+1)]
    U[0]=0
    for j in range(n):
        if pattern[i][j]==True:
            cost+=books[j][0]
            for k in range(1,m+1):
                U[k]-=books[j][k]
                if max(U)==0:
                    answer.append(cost)
                    break
                    
print(min(answer))

Submission status: Runtime Error

Solution code:
n, m, x = map(int, input().split())
c = [0] * n
a = [0] * n
for i in range(n):
    xs = list(map(int, input().split()))
    c[i] = xs[0]
    a[i] = xs[1:]
ans = 10 ** 9
for i in range(2 ** n):
    csum = 0
    asum = [0] * n
    for j in range(n):
        if (i >> j) & 1:
            csum += c[j]
            for k in range(m):
                asum[k] += a[j][k]
    if len(list(filter(lambda v: v >= x, asum))) == m:
        ans = min(ans, csum)
print(-1 if ans == 10 ** 9 else ans)

Submission status: Runtime Error

Solution code:
'''
M個調べる
A1 + A2
B1 + B2
C1 + C2
D1 + D2
すべての？[i]で １０以上、さらに
'''

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

C = []
A = []
for i in range(N):
    t = list(map(int, input().split()))
    C.append(t[0])
    A.append(t[1:]) # 1から最後まで

result = -1

# << は 左への bit シフト。 シフトした分、１０進数で2^N分増える
#全検索
for i in range(2 << N):
    # t 
    t = [0] * M 
    c = 0

    for j in range(N):
        #以下フラグが立っていなかったら、
        if (i >> j) & 1 == 0:
            continue #以下処理を飛ばしてforに戻る
        # cに金額を足している
        c += C[j]
        for k in range(N):
            t[k] += A[j][k]
    if all(x >= X for x in t):
        if result == -1:
            result = c
        else:
            result = min(result, c)
print(result)

Submission status: Runtime Error

Solution code:
M,N,X=map(int,input().split())
C=[list(map(int,input().split())) for i in range(N)]
INF=float("inf")
ans=INF

for i in range(1,2**N):
    skills=[0]*M
    total_cost=0
    for j in range(N):
        if ((i>>j)&1):
            total_cost+=C[j][0]
            for k in range(M):
                skills[k]+=C[j][k+1]
    if min(skills)>=X:
        ans=min(ans,total_cost)
        
print(ans if ans != INF else -1)

Submission status: Runtime Error

Solution code:
n,m,x = map(int,input().split())
for i in range(n):
  c.append(list(map(int,input().split())))
print(c)
result = -1
for i in range(2 ** n):
  ct = 0
  t = [0] * m
  for b in range(1, n + 1):
    if i & b > 0:
      ct += c[b - 1][0]
      for j in range(1, m + 1):
        t[j - 1] += c[b - 1][j]
  if result == -1 or ct < result:
    r = 1
    for ti in t:
      if ti < x:
        r = 0
    if r == 1:
      print(ct)
      print(t)
      result = ct
print(result)

Submission status: Runtime Error

Solution code:
n, m, x = map(int, input().split())
#n,m,x,i,j,l,money,k,o
books = []
for i in range(n):
    books.append(list(map(int, input().split())))
books = sorted(books, reverse=False)
print(books)#

ans = 10 ** 6
import itertools
for i in range(n+1):
    for j in itertools.combinations(books, i):#j:組み合わせ
#        print(j)#
        l = [0] * n #理解度
        money = 0
        for k in j:#k:組み合わせの中の１冊
#            print(k)#
            money += k[0]  #費用
#            print(money)#
            for o in range(1, m + 1):
                l[o-1] += k[o]  #lが理解度、kが本
#        print(money,l)
        if all(a >=x for a in l):
            if money < ans:
                ans = money

if ans == 10 ** 6:
    print(-1)
else:
    print(ans)

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
    n, m, x = list(map(int, input().split()))

    # 空のリストを作って、appendで追加していきます
    c = []  # 参考書の値段です
    a = []  # 各参考書に入る理解度です

    for i in range(n):
        c_temp, *a_temp = list(map(int, input().split()))  # こうすると、2つ目以降をリストで受け取れます
        c.append(c_temp)
        a.append(a_temp)

    INF = float("inf")
    ans = INF

    for bit in range(1 << n):
        price = calc_price(bit)  # 条件を満たすならそのときの値段、満たさないならINFが返ってきます
        ans = min(ans, price)  # 答えを更新します

    if ans == INF:
        print(-1)  # どうやっても条件を満たせなかった
    else:
        print(ans)
        
def calc_price(bit):
    price_total = 0  # 値段の合計
    learn_total = [0] * m  # 理解度

    for i in range(n):
        if (bit >> i) & 1:  # i桁目が0か1か見て、i冊目を買うか買わないか判定します
            price_total += c[i]  # 買うので、i冊目の値段を加算します
            learn = a[i]  # 「i冊目の参考書を読んで増える、各アルゴリズムの理解度」のリストです
            for j, la in enumerate(learn):  # 理解度を加算します enumerateを使うと、range(n)よりスマートです
                learn_total[j] += la

    # 条件を満たすか、check関数で確認します
    if check(learn_total):
        return price_total 　# 条件を満たすので、値段を返します
    else:
        return INF # 条件を満たさないので、INFを返します
     
  def check(learn_total):
    for i in range(m):
        if learn_total[i] < x:
            return False  # 1個でもx未満ならFalse
    return True # 全部x以上ならTrue

Submission status: Runtime Error

Solution code:
def calc_price(bit):
	# 値段の合計
	price_total = 0
  # 理解度
	learn_total = [0] * m 
	
	for i in range(n):
		# i桁目が0か1か見て、i冊目を買うか買わないか判定します
		if (bit >> i) & 1;
			# 買うので、i冊目の値段を加算します
			price_total += c[i]
			# 「i冊目の参考書を読んで増える、各アルゴリズムの理解度」のリストです
			learn = a[i]
			# 理解度を加算、
      # enumerateを使うと、range(n)よりスマートです
      # 引数にリストなどのイテラブルオブジェクトを指定する。
			for j, la in enumerate(learn):
				learn_total[j] += la

			#条件を満たすかどうかcheck関数で確認
			if check(learn_total):
			# 条件を満たすので、値段を返します
				return price_total
			else:
			# 条件を満たさないので、INFを返します
				return INF

def check(learn_total):
    for i in range(m):
        if learn_total[i] < x:
            return False  # 1個でもx未満ならFalse
    return True # 全部x以上ならTrue

if __name__ == '__main__':
	n, m, x = list(map(int, input().split()))
	
	#からのリストを作ってappendで追加していく
	c = [] #参考書の値段
	a = [] #書く参考書に入る理解度
	
	for i in range(n):
		c_temp, a_temp = list(map(int, input().split()))
		c.append(c_temp)
	  a.append(a_temp)
	
	INF = float("inf")
	ans = INF
	
	for bit in range(1 << n):
		# 条件を満たすならそのときの値段、満たさないならINFが返ってきます
		price = calc_price(bit)
	  # 答えを更新
		ans = min(ans, price)
	
	if ans == INF:
		price(-1)
	else:
	  price(ans)

Submission status: Runtime Error

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

#からのリストを作ってappendで追加していく
c = [] #参考書の値段
a = [] #書く参考書に入る理解度

def calc_price(bit):
	# 値段の合計
	price_total = 0
  # 理解度
	learn_total = [0] * m 
	
	for i in range(n):
		# i桁目が0か1か見て、i冊目を買うか買わないか判定します
		if (bit >> i) & 1;
			# 買うので、i冊目の値段を加算します
			price_total += c[i]
			# 「i冊目の参考書を読んで増える、各アルゴリズムの理解度」のリストです
			learn = a[i]
			# 理解度を加算、
      # enumerateを使うと、range(n)よりスマートです
      # 引数にリストなどのイテラブルオブジェクトを指定する。
			for j, la in enumerate(learn):
				learn_total[j] += la

			#条件を満たすかどうかcheck関数で確認
			if check(learn_total):
			# 条件を満たすので、値段を返します
				return price_total
			else:
			# 条件を満たさないので、INFを返します
				return INF

def check(learn_total):
    for i in range(m):
        if learn_total[i] < x:
            return False  # 1個でもx未満ならFalse
    return True # 全部x以上ならTrue

for i in range(n):
	c_temp, a_temp = list(map(int, input().split()))
	c.append(c_temp)
  a.append(a_temp)

INF = float("inf")
ans = INF

for bit in range(1 << n):
	# 条件を満たすならそのときの値段、満たさないならINFが返ってきます
	price = calc_price(bit)
  # 答えを更新
	ans = min(ans, price)

if ans == INF:
	price(-1)
else:
  price(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

def dfs(i, cost, A):
    if i == n-1:
        global ans
        if cost < ans and all([ai>=x for ai in A]):
            ans = cost
        return
    
    i += 1
    dfs(i, cost, A[:])
    dfs(i, cost+c[i], A[:]+a[i])

    
        
        

if __name__ == "__main__":
    n, m, x = map(int, input().split())
    c, a = [None]*n, np.array([None]*n)
    for i in range(n):
        c[i], *a[i] = map(int, input().split())
    ans = 10**20
    dfs(-1, 0, np.array([0]*m))
    print(ans)

Submission status: Runtime Error

Solution code:
import itertools
n,m,x = map(int,input().split())
book = []
for _ in range(n):
    book.append(list(map(int,input().split())))

buy = list(itertools.product([0,1],repeat=n))

money = []

for i in range(len(buy)):
    algo = [0 for _ in range(m)]
    money_tmp = 0
    #j冊目の本
    for j in range(len(buy[i])):
        for k in range(m):
            algo[j] += book[k][j+1] * buy[i][k]
        money_tmp += book[j][0]*buy[i][j]
    algo.sort()
    #print(money_tmp)
    if algo[0] >= x:
        money.append(money_tmp)
        
if len(money) > 0:    
    print(min(money))
else:
    print(-1)

Submission status: Runtime Error

Solution code:
import itertools
n,m,x = map(int,input().split())
book = []
for _ in range(n):
    book.append(list(map(int,input().split())))

buy = list(itertools.product([0,1],repeat=m))

money = []

for i in range(len(buy)):
    algo = [0 for _ in range(m)]
    money_tmp = 0
    #j冊目の本
    for j in range(len(buy[i])):
        for k in range(m):
            algo[j] += book[k][j+1] * buy[i][k]
        money_tmp += book[j][0]*buy[i][j]
    algo.sort()
    if algo[0] >= x:
        money.append(money_tmp)
if len(money) > 0:    
    print(min(money))
else:
    print(-1)

Submission status: Runtime Error

Solution code:
N,M,X = map(int,input().split())
A = []
cost = []
for i in range(N):
    a = list(map(int,input().split()))
    A.append(a[1:])
    cost.append(a[0])
ans = float('inf')
for i in range(2**N):
    I = bin(i)[2:]
    I = I.zfill(M)
    tmp = [0]*M
    buy = 0
    for j in range(len(I)):
        if I[j]=='1':
            for k in range(len(A[j])):
                tmp[k] += A[j][k]
            buy += cost[j]
    if all(tmp[i]>=X for i in range(len(tmp))):
        ans = min(ans,buy)
ans = -1 if ans ==float('inf') else ans
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
import sys
sys.setrecursionlimit(1000000)

def dfs(cost, i, A):
    if i == n-1:
        global ans
        if cost < ans and all([ai>=x for ai in A]):
            ans = cost
        return
    i += 1
    dfs(cost, i, A)
    dfs(cost+c[i], i, A+a[i])

    

if __name__ == "__main__":
    n, m, x = map(int, input().split())
    c, a = [None]*n, np.array([None]*n)
    for i in range(n):
        c[i], *a[i] = map(int, input().split())
    ans = 10**10
    dfs(0, -1, np.array([0]*m))
    if ans == 10**10:
        print(-1)
    else:
        print(ans)

Submission status: Runtime Error

Solution code:
from math import inf
n, m, x = map(int, input().split())
ca = list()
for _ in range(n):
    ca.append(list(map(int, input().split())))

money = inf
tmp = 1
for i in range(n):
    tmp += 2**i
for i in range(tmp):
    B = str(format(i, str(n).zfill(n)+'b'))
    j = 0
    cnt = 0
    a = [0]*m
    for ch in B:
        if ch == '1':
            cnt += ca[j][0]
            for k in range(1, m+1):
                a[k-1] += ca[j][k]
        j += 1
    if a[0] >= x and a[1] >= x and a[2] >= x:
        money = min(cnt, money)

print(-1 if money == inf else money)

Submission status: Runtime Error

Solution code:
a,b,import numpy as np
import itertools
n, m, x = map(int, input().split())
a = np.dot([i for i in itertools.product([0, 1], repeat = n)],
           [list(map(int, input().split())) for _ in range(n)])
b = np.prod(a[:, 1:(m + 1)] >= x, axis = 1, dtype = bool)
print(min(a[:, 0][b]) if b.sum() else '-1')

Submission status: Runtime Error

Solution code:
a,b,import numpy as np
import itertools
n, m, x = map(int, input().split())
a = np.dot([i for i in itertools.product([0, 1], repeat = n)],
           [list(map(int, input().split())) for _ in range(n)])
b = np.prod(a[:, 1:(m + 1)] >= x, axis = 1, dtype = bool)
print(min(a[:, 0][b]) if b.sum() else '-1')

Submission status: Runtime Error

Solution code:
import numpy as np
n,m,x=map(int,input().split())
c=[]
a=[]
ans=10**6
for x in range(n):
  line=list(map(int,input().split()))
  c.append(line[0])
  a.append(line[1:])
a=np.array(a)
for i in range(2**n):
  level=np.zeros(m)
  price=0
  for j in range(n):
    if ((i>>j)&1):
      level+=a[j]
      price+=c[j]
	for k in range(m):
      if np.amin(level)>=x and price<=ans:
        ans=price
if ans==10**6:
  print(-1)
else:
  print(ans)

Submission status: Runtime Error

Solution code:
N,M,X = map(int, input().split())
C = [list(map(int, input().split())) for i in range(N)]

# C = [[60, 2, 2, 4], [70, 8, 7, 9], [50, 2, 3, 9]]

P = [row[0] for row in C]
A = [row[1:M+1] for row in C]

K = [0 for i in range(2**N)]
G = [[0,0,0] for i in range(2**N)]
for i in range(2**N):
    i2 = format(i, '012b')
    s = 0
    for k in range(N):
        K[i] += int(i2[11-k])*P[k]
        for j in range(M):
            G[i][j] += int(i2[11-k])*A[k][j]

J = [[K[i],G[i]] for i in range(2**N)]

t = 0
for i in range(2**N):
    for j in range(M):
        if (J[i][1])[j] < X:
            break
        if j == M-1:
            t = 1
            print(J[i][0])
    if t== 1:
        break

if t==0:
    print(-1)

Submission status: Runtime Error

Solution code:
N, M, X = map(int, input().split())
C = [0] * N
A = []

for __ in range(N):
    nums = list(map(int, input().split()))
    C[__] = nums[0]
    A.append(nums[1:])
mincost = 10e9
ok = False
for i in range(1 << N):
    cost = 0
    skill = [0] * M

    for u in range(N):
        if i & (1<<u):
            cost += C[u]
            for si, s in enumerate(A[u]):
                skill[si] += s
    
    # check
    if all([s >= X for s in skill]):
        ok = True
        if mincost > cost:
            mincost = cost

print(mincost if ok else -1)
 dp

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
n,m,x=map(int,input().split())
c=[]
A=[]
for i in range(n):
    inp=tuple(map(int,input().split()))
    c.append(inp[0])
    A.append(list(inp[1:]))
A=np.array(A,dtype='uint64')
M=2**n
minmoney=float('inf')
for i in range(M):
    cur=np.zeros(n,dtype='uint64')
    money=0
    for j in range(n):
        if i>>j & 1:
            cur+=A[j]
            money+=c[j]
    if min(cur)>=x:
        if money<minmoney:
            minmoney=money
if minmoney==float('inf'):
    print(-1)
else:
    print(minmoney)

Submission status: Runtime Error

Solution code:
import numpy as np
n,m,x=map(int,input().split())
c=[]
A=[]
for i in range(n):
    inp=tuple(map(int,input().split()))
    c.append(inp[0])
    A.append(list(inp[1:]))
A=np.array(A,dtype='int32')
M=2**n
minmoney=float('inf')
for i in range(M):
    cur=np.zeros(n,dtype='int32')
    money=0
    for j in range(n):
        if i>>j & 1:
            cur+=A[j]
            money+=c[j]
    if min(cur)>=x:
        if money<minmoney:
            minmoney=money
if minmoney==float('inf'):
    print(-1)
else:
    print(minmoney)

Submission status: Runtime Error

Solution code:
def cloth(a):
    n=len(a)
    r=[0]*3
    for i in range(n):
        r[0]+=a[i][0]
        r[1]+=a[i][1]
        r[2]+=a[i][2]
    return r
a,b,c=map(int,input().split())
d=[]
for i in range(a):
    n=list(map(int,input().split()))
    d.append(n)

m=[]
q=[]

for i in range(2**a):
    score=[]
    total=0
    for j in range(a):
        if ((i>>j)&1):
            score.append(d[j][1:b+1])
            total+=d[j][0]
    m.append([score,total])

large=len(m)
決勝=[]
n=0
q=0
while True:
    q=len(m[n][0])
    if q==a:
        break
    r=cloth(m[n][0])
    n+=1
    if r[0]<c or r[1]<c or r[2]<c:
        continue
    else:
        決勝.append(m[n][1])

u=cloth(m[-1][0])
if len(決勝)==0 and len([i for i in u if i>=c])==3:
    print(m[-1][1])

elif len(決勝)==0:
    print(-1)
else:
    print(min(決勝))

Submission status: Runtime Error

Solution code:
def cloth(a):
    n=len(a)
    r=[0]*3
    for i in range(n):
        r[0]+=a[i][0]
        r[1]+=a[i][1]
        r[2]+=a[i][2]
    return r
a,b,c=map(int,input().split())
d=[]
for i in range(a):
    n=list(map(int,input().split()))
    d.append(n)

m=[]
q=[]

for i in range(2**a):
    score=[]
    total=0
    for j in range(a):
        if ((i>>j)&1):
            score.append(d[j][1:b+1])
            total+=d[j][0]
    m.append([score,total])

large=len(m)
決勝=[]
n=0
q=0
while True:
    q=len(m[n][0])
    if q==a:
        break
    r=cloth(m[n][0])
    n+=1
    if r[0]<c or r[1]<c or r[2]<c:
        continue
    else:
        決勝.append(m[n-1][1])

u=cloth(m[-1][0])
if len(決勝)==0 and len([i for i in u if i>=c])==3:
    print(m[-1][1])

elif len(決勝)==0:
    print(-1)
else:
    print(min(決勝))

Submission status: Runtime Error

Solution code:
import numpy as np

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



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



ans = 1 << 31

for i in range(2**n):
    tmp = np.zeros(4)
    for j in range(n):
        if i % (2**j):
            tmp += caa[j]
        if min(tmp[1:]) >= x:
            ans = min(ans, tmp[0])

if ans != 1<<31:
    print(int(ans))
else:
    print(-1)

Submission status: Runtime Error

Solution code:
n, m, x = [*map(int, input().split())]
k = []
ans = 10 ** 6
for i in range(n):
    c, *a = [*map(int, input().split())]
    s += c
    k.append([c, *a])

for i in range(2 ** n):
    cost = 0
    skills = [0] * m
    for j in range(n):
        if ((i >> j) & 1):
            cost += k[j][0]
            for s, t in enumerate(k[j][1:]):
                skills[s] += t
            if all(map(lambda skill: skill >= x, skills)):
                ans = min(ans, cost)
print(-1 if ans == 10 ** 6 else ans)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python

def main():
    N, M, X = map(int, input().split())
    mat = [list(map(int, input().split())) for _ in range(N)]

    ans = 12 * (10 ** 5) +1
    for i in range(1<<N):
        tmp = [0] * (M+1)
        for j in range(N):
            if (i>>j)&1:
                tmp = [x+y for x, y in zip(tmp, mat[j])]
        if all(tmp[i] >= X for i in range(1, M):
                ans = min(ans, tmp[0])

    print('-1') if ans == 12 * (10 ** 5) +1 else print(ans)
            
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N,M,X = map(int,input().split())
li = []
import numpy as np
C = []

for _ in range(M):
    c,*a = map(int,input().split())
    li.append(np.array(a))
    C.append(c)

counter = []

for i in range(1<<N):
    skill_li = np.zeros(M)
    sum_price = 0
    for k in range(N):
        if (i>>k) & 1:
            skill_li += li[k]
            sum_price += C[k]
    if all(skill_li>=X):
        counter.append(sum_price)
if len(counter)==0:
    print(-1)
else:
    print(min(counter))

Submission status: Runtime Error

Solution code:
N,M,X = map(int,input().split())
C=[0 for i in range(N)]
A=[[] for i in range(N)]
min_cost=10000000000
for i in range(N):
    C[i],*A[i]=map(int,input().split())
for i in range(1<<N):
    L=[0 for i in range(M)]
    cost=0
    for j in range(N):
        if 1&(i>>j):
            for k in range(M):
                L[k]+=A[j][k]
            cost+=C[j]
    if min(L)>=X:
      min_cost=min(min_cost,cost)
if min_cost=10000000000:
  print(-1)
else:
  print(min_cost)

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 = 0
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:
            okane = result[0][0]     

if okane == 0:
    print(-1)
else:
    print(okane)

Submission status: Runtime Error

Solution code:
import itertools
import pandas as pd

num_list = [i for i in range 12]
p = itertools.permutations(num_list, 12)
for i in range(5):
  print(p[i])

Submission status: Runtime Error

Solution code:
N, M, X = map(int, input().split())
book = [[map(int, input().split())] for i in range(N)]

min_value = -1
for i in range(2**N):
  sum = [0 for k in range(M+1)]
  for j in range(N):
    if (i >> j) & 1:
      sum = [x+y for x, y in zip(sum, book[N+1])]
  if min(sum[1:]) >= X and min_value > sum[0]:
    min_value = sum[0]

print(min_value)

Submission status: Runtime Error

Solution code:
import numpy as np
N,M,X = map(int,input().split())

clist=[]
for i in range(N):
    clist.append(list(map(int,input().split())))

#print(clist)

total_all=[]
for i in range(2**N):
    total=np.zeros(M+1)
    for j in range(N):
        
        # iを2進数表記した場合の下から数えてj番目が1ならtrue
        if ((i >> j) & 1):
            total=total+np.array(clist[j])
    total_all.append(list(total))

#print(total_all)
ans=[]
#print(total_all[1][1:M+1])

for i in range(len(total_all)):
    if min(total_all[i][1:M])>=X:
        ans.append(total_all[i][0])

if len(ans)>=1:
    print(int(min(ans)))
else:
    print("-1")

Submission status: Runtime Error

Solution code:
import numpy as np
N,M,X = map(int,input().split())

clist=[]
for i in range(N):
    clist.append(list(map(int,input().split())))

#print(clist)

total_all=[]
for i in range(2**N):
    total=np.zeros(M+1)
    for j in range(N):
        
        # iを2進数表記した場合の下から数えてj番目が1ならtrue
        if ((i >> j) & 1):
            total=total+np.array(clist[j])
    total_all.append(list(total))

#print(total_all)
ans=[]
for i in range(len(total_all)):
    if min(total_all[i][1:M])>=10:
        ans.append(total_all[i][0])

if len(ans)>=1:
    print(int(min(ans)))
else:
    print("-1")

Submission status: Runtime Error

Solution code:
import itertools
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m, x = map(int, readline().split())
c = [list(map(int, readline().split())) for _ in range(n)]

ans = 10 ** 9 + 7
for l in list(itertools.product([0, 1], repeat=n)):
    cart = [0] * (m + 1)
    for i, a in enumerate(l):
        if a == 1:
        array = c[i]
        cart = list(map(lambda x,y: x+y, cart, array))
    if min(cart[1::]) >= x:
        ans = min(ans, cart[0])
print(ans if ans != 10 ** 9 + 7 else '-1')

Submission status: Runtime Error

Solution code:

Submission status: Runtime Error

Solution code:
import numpy as np
import sys
sys.setrecursionlimit(100000)


def main():
    n, m, x = map(int, input().split())
    cl = [None]*n
    al = [None]*n
    for i in range(n):
        cl[i], *al[i] = map(int, input().split())
    
    def dfs(i, cost, A):
        if i == n-1:
            global ans
            if all([a >= x for a in A]) and cost < ans:
                ans = cost
            return
        i += 1
        dfs(i, cost, A[:])
        dfs(i, cost+cl[i], A[:]+al[i])
    
    dfs(-1, 0, np.array([0]*n))
    
    print(ans)
        

if __name__ == "__main__":
    ans = 10**7
    main()

Submission status: Runtime Error

Solution code:
import numpy as np

def main():
    n, m, x = map(int, input().split())
    cl = [None]*n
    al = [None]*n
    for i in range(n):
        cl[i], *al[i] = map(int, input().split())
    
    def dfs(i, cost, A):
        if i == n-1:
            global ans
            if all([a >= x for a in A]) and cost < ans:
                ans = cost
            return
        i += 1
        dfs(i, cost, A[:])
        dfs(i, cost+cl[i], A[:]+al[i])
    
    dfs(-1, 0, np.array([0]*n))
    
    print(ans)
        

if __name__ == "__main__":
    ans = 10**7
    main()

Submission status: Runtime Error

Solution code:
import numpy as np

N, M, X = list(map(int, input().split()))
a = np.zeros((N, M))
C = np.zeros(N)
for i in range(N):
    tmp = list(map(int, input().split()))
    C[i] += tmp[0]
    a[i] += tmp[1:]

a = a.reshape(M, N)

answer_price = 2**10

for i in range(1 << N):
    tmp = np.zeros(M)
    cost = 0
    for j in range(N):
        if i % 2 == 1:
            tmp += a[j]
            cost += C[j]
        i = i >> 1
    if all(tmp >= X) and cost < answer_price:
        answer_price = cost
        
if answer_price == 2**10:
    print("-1")
else:
    print(int(answer_price))

Submission status: Runtime Error

Solution code:
import numpy as np

N, M, X = list(map(int, input().split()))
a = np.zeros((M, N))
C = np.zeros(N)
for i in range(N):
    tmp = list(map(int, input().split()))
    C[i] += tmp[0]
    a[i] += tmp[1:]

a = a.reshape(M, N)

answer_price = 2**10

for i in range(1 << N):
    tmp = np.zeros(M)
    cost = 0
    for j in range(N):
        if i % 2 == 1:
            tmp += a[j]
            cost += C[j]
        i = i >> 1
    if all(tmp >= X) and cost < answer_price:
        answer_price = cost
        
if answer_price == 2**10:
    print("-1")
else:
    print(int(answer_price))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#https://atcoder.jp/contests/abc167/tasks/abc167_c C - Skill Up
import numpy as np
import math
from itertools import combinations
N,M,X=list(map(int,input().split()))
book_dict={}
for i in range(N):
    book_dict[i] = list(map(int,input().split()))

answer = (10**5*12)+1
for i in range(N,0,-1):
    current_book_number=0    
    for v in combinations(book_dict.keys(), i):
        ##要件を満たさない組み合わせカウント
        search_book = list(map(lambda x:book_dict[x],list(v)))
        sum_search_book = np.array(np.sum(search_book,axis = 0))
        if (np.count_nonzero(sum_search_book[1:] >= X) == M) and sum_search_book[0] < answer:
            answer = sum_search_book[0]
        else:
            current_book_number+=1
    ##どの組み合わせでも達成できない場合は、これ以上本を減らしても意味ない    
    if current_book_number==int(math.factorial(N)/(math.factorial(i)*math.factorial(N-i))):
        break:                                                                                 
    
if answer == (10**5*12)+1:
    answer = -1

print(answer)

Submission status: Runtime Error

Solution code:
#https://atcoder.jp/contests/abc167/tasks/abc167_c C - Skill Up
import numpy as np
from itertools import combinations
N,M,X=list(map(int,input().split()))
book_dict={}
for i in range(M):
    book_dict[i] = list(map(int,input().split()))

answer = (10**5*12)+1
for i in range(M,0,-1):
    for v in combinations(book_dict.keys(), i):
        search_book = list(map(lambda x:book_dict[x],list(v)))
        sum_search_book = np.array(np.sum(search_book,axis = 0))
        if (np.count_nonzero(sum_search_book[1:] >= X) == N) and sum_search_book[0] < answer:
            answer = sum_search_book[0]
                                                                                 
    
if answer == (10**5*12)+1:
    answer = -1

print(answer)

Submission status: Runtime Error

Solution code:
#https://atcoder.jp/contests/abc167/tasks/abc167_c C - Skill Up
import numpy as np
from itertools import combinations
N,M,X=list(map(int,input().split()))
book_dict={}
for i in range(M):
    book_dict[i] = list(map(int,input().split()))

answer = (10**5*12)+1
for i in range(M,0,-1):
    for v in combinations(book_dict.keys(), i):
        search_book = list(map(lambda x:book_dict[x],list(v)))
        sum_search_book = np.array(np.sum(search_book,axis = 0))
        if (np.count_nonzero(sum_search_book[1:] >= X) == N) and sum_search_book[0] < answer:
            answer = sum_search_book[0]
            print(ansew)
                                                                                 

    
if answer == (10**5*12)+1:
    answer = -1

print(answer)