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: Wrong Answer

Solution code:
def intlist(x):
    y = []
    for i in range(len(x)):
        y.append(int(x[i]))
    return y
 
N, M, X = map(int, input().split())
price = -1

L = []
a = []

suit =[]
for i in range(M+1):
    a.append(0)
    
#for i in range(2**N):
#    suit.append([])

for i in range(N):
    text = input().split()
    L.append(intlist(text))

def buy(x,y):
    
    if x + y <= N:
        
        for i in range(0,M+1):
            #print("x+y=",x+y)
            #print("i=",i)
            a[i] += L[x+y-1][i]
            
        print("a",a)
        if x + y == N:
            score = a[1:len(a)]
            
            if min(score) >= X:
                suit.append(a.copy())
                
        elif x + y != N:
            buy(x+1,y)
            for i in range(0,M+1):
                a[i] -= L[x+y][i]
            
            notbuy(x,y+1)


def notbuy(x,y):
    print("notbuy",x,y)
    if x + y <= N:
        
        if x + y == N:
            score = a[1:len(a)]
            if min(score) >= X:
                suit.append(a.copy())
                    
                
        elif x + y != N:
            buy(x+1,y)
            for i in range(0,M+1):
                a[i] -= L[x+y][i]
            notbuy(x,y+1)    

def textbook(x,y):
    buy(x+1,y)
    for i in range(0,M+1):
        a[i] -= L[x+y][i]
    notbuy(x,y+1)

textbook(0,0)

b = []

if suit != []:
    for i in range(len(suit)):
        for j in range(len(suit)-1):
            if suit[j] > suit[j+1]:
                b = suit[j]
                suit[j] = suit[j+1]
                suit[j+1] = b
    price = suit[0][0]


print(price)

Submission status: Wrong Answer

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 = -1
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 and not C_MIN == -1:
            C_MIN = C_SUM
            
if C_MIN == -1:
    print("-1")
else:
    print(int(C_MIN))

Submission status: Wrong Answer

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

for i in range(n**2 - 1):
    reference_book = []
    book_price = 0
    for j in range(n):
        if (i >> j) & 1:
            reference_book.append(books[j])
            book_price += books[j][0]
    print(reference_book)
    err = 0
    for k in range(1, m+1):
        r = [row[k] for row in reference_book]
        if sum(r) < x:
            err += 1
    if err == 0:
        book_total_price.append(book_price)
if book_total_price == []:
    print('-1')
else:
    print(min(book_total_price))

Submission status: Wrong Answer

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

for i in range(n ** 2):
    reference_book = []
    book_price = 0
    for j in range(n):
        if (i >> j) & 1:
            reference_book.append(books[j])
            book_price += books[j][0]
    err = 0
    for k in range(1, m+1):
        r = [row[k] for row in reference_book]
        if sum(r) < x:
            err += 1
    if err == 0:
        book_total_price.append(book_price)
if book_total_price == []:
    print('-1')
else:
    print(min(book_total_price))

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy
def main():
    N, M, X = map(int, input().split())
    book = []
    ans = 1000000
    for i in range(N):
        info = [int(i) for i in input().split()]
        book.append(info)
    for i in range(1 << N):
        a = []
        for j in range(M + 1):
            a.append(0)    
        for j in range(N):
            if (i >> j) & 1:
                for t in range(M + 1):
                    a[t] += book[j][t]
        for j in range(1, M + 1):
            if a[j] < X:
                a[0] = 1000000
                break
        ans = min(ans, a[0])
    if ans >= 1000000:
        ans = -1
    print(ans)







if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N,M,X=map(int, input().split())
A=list(list(map(int, input().split())) for _ in range(N))
ans=N*10**5+1
import itertools
import numpy as np
for i in range(1,M+1):
    for aa in list(itertools.combinations(A,i)):
        tmp=np.array([0]*len(A[0]))
        for a in aa:
            a = np.array(a)
            tmp=tmp+a
        if min(tmp[1:])>=X:
            ans=min(ans,tmp[0])       
print(ans if ans!=(N*10**5+1) else -1)

Submission status: Wrong Answer

Solution code:
N,M,X=map(int, input().split())
A=list(list(map(int, input().split())) for _ in range(N))
ans=M*10**5+1
import itertools
import numpy as np
for i in range(1,M+1):
    for aa in list(itertools.combinations(A,i)):
        tmp=np.array([0]*len(A[0]))
        for a in aa:
            a = np.array(a)
            tmp=tmp+a
        if min(tmp[1:])>=X:
            ans=min(ans,tmp[0])       
print(ans if ans!=(M*10**5+1) else -1)

Submission status: Wrong Answer

Solution code:
from itertools import product
n, m, x = map(int, input().split())
costs = []
gets = []
for i in range(n):
    cost, *argo = map(int, input().split())
    costs.append(cost)
    gets.append(argo)

    
bits_list = list(product([0,1], repeat=n))
min_cost = float('inf')
cnt = 0
for bits in bits_list:
    tmp_cost = 0
    tmp_argo = [0] * m
    for i, v in enumerate(bits):
        if v:
            tmp_cost += costs[i]
            for j, p in enumerate(gets[i]):
                tmp_argo[j] += p
                
    if all(map(lambda X:X>x, tmp_argo)):
        min_cost = min(min_cost, tmp_cost)
        cnt = 1
if cnt:
    print(min_cost)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
B=[list(map(int,input().split())) for i in range(n)]
ANS = 1 << 100
for i in range(1 << n):
    SCORE = [0] * m
    MONEY = 0
    for j in range(n):
        if (1 << j) & i != 0:
            MONEY+=B[j][0]
            for k in range(m):
                SCORE[k] += B[j][k]
    if min(SCORE) >= x:
        ANS = min(ANS,MONEY)
if ANS == 1 << 100:
    print(-1)
else:
    print(ANS)

Submission status: Wrong Answer

Solution code:

n,m,k=map(int,input().split())
A=[]
for i in range(n):
    row=list(map(int,input().split()))
    A.append(row)
mn=10**9
for i in range(int(2**n)):
    x=bin(i)[2:]
    x=("0"*(n-len(x)))+x
    curr=[0 for ptr in range(m)]
    s=0
    for j in range(n):
        if(x[j]=="1"):
            s+=A[j][0]
            curr=[curr[ptr]+A[j][ptr+1] for ptr in range(m) ]

    curr=[curr[ptr]>=k for ptr in range(m)]
    curr=list(set(curr))
    if(curr==[True]):
        if(s<mn):
            mn=s
print(mn)

Submission status: Wrong Answer

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 = 0
flag = False

for i in range(1, n ** 2 + 1):
    b = np.zeros(m+1)

    for k in range(n):
        if ((i >> k) & 1):
            b += a[k]
    
    if np.all(b[1:] >= x):
        if flag == False:
            c_min = b[0]
            flag = True
        else:
            c_min = min(c_min, b[0])
        

c_min = int(c_min)

if flag == False:
    c_min = -1

print(c_min)

Submission status: Wrong Answer

Solution code:
n,m,x = map(int, input().split())
matrix = [list(map(int, input().split())) for i in range(n)]
collum = [[x[i] for x in matrix] for i in range(m + 1)]
row_sum = []
flag = True

for i in range(len(collum)):
  sum = 0
  for j in range(len(collum[i])):
    sum += collum[i][j]
  row_sum.append(sum)

for a, i in enumerate(row_sum):
  if a == 0:
    continue
  if x > i:
    flag = False
    break
    
if flag == True:
  print(row_sum[0])
else:
  print(-1)

Submission status: Wrong Answer

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):
    b = np.zeros(m+1)

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

if flag == False:
    c_min = -1

print(int(c_min))

Submission status: Wrong Answer

Solution code:
def main():
    N,M,X=map(int, input().split())
    A=[list(map(int, input().split())) for _ in range(N)]
    ans=10**10
    for i in range(2**N):
        b=i+2**N
        c=0
        l=[0]*M
        ok=True
        for j in range(N):
            if b>>j&1 == 1:
                c+=A[j][0]
                for k in range(M):
                    l[k]+=A[j][k+1]
        for x in l:
            if x < X: ok = False 
        if ok:
            ans = min(ans, c)
    if ans==10**5*N: print('-1')
    else: print(ans)

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N,M,X=map(int, input().split())
    A=[list(map(int, input().split())) for _ in range(N)]
    ans=10**5*N
    for i in range(2**N):
        b=i+2**N
        c=0
        l=[0]*M
        ok=True
        for j in range(N):
            if b>>j&1 == 1:
                c+=A[j][0]
                for k in range(M):
                    l[k]+=A[j][k+1]
        for x in l:
            if x < X: ok = False 
        if ok:
            ans = min(ans, c)
    if ans==10**5*N: print('-1')
    else: print(ans)

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
def intlist(x):
    y = []
    for i in range(len(x)):
        y.append(int(x[i]))
    return y

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

L = []
a = []

for i in range(N):
    text = input().split()
    L.append(intlist(text))
    
for i in range(N):
    for j in range(N-1):
        if L[j] > L[j+1]:
            a = L[j]
            L[j] = L[j+1]
            L[j+1] = a

score = []
count = 0
money = -1
money_count = 0


for i in range(M):            
    score.append(0)
            
for i in range(N):
    money_count = money_count + L[i][0]
    for j in range(M):
        score[j] = score[j] + L[i][j+1]
    if min(score) >= X:
        money = money_count
        break


score2 = score

if money != -1:

    for i in range(N):
        for j in range(M):
            score2[j] -= L[len(L)-1-i][j+1]
            print(score2)
        if min(score2) >= X:
            money = money - L[len(L)-1-i][0]
        else:
            for k in range(M):
                score2[k] += L[len(L)-1-i][k+1]
       
        
          
print(money)

Submission status: Wrong Answer

Solution code:
import numpy as np

N,M,X = map(int, input().split())
books = []
for i in range(N):
  tmp_book = list(map(int, input().split()))
  books.append(tmp_book)

sorted(books)
books = np.array(books)
#print(books)
flag = 1
for i in range(M):
  if sum(books[:,1+i]) < X:
    flag = 0
    break

if flag == 0:	# 目標を達成できない場合
  print(-1)
else:
  total_price = 0
  learning_rates = np.zeros(M)
  while 1:
    high_eff, tmp_eff = 0, 0
    high_eff_price = 0
    high_eff_idx = 0
    high_learning_rate = np.zeros(M)
    for i in range(len(books)):
      tmp_eff = sum(books[i,1:M+1])/books[i,0]	# 費用対効果を算出
      if tmp_eff > high_eff:			# 費用対効果が高い場合
        high_eff = tmp_eff				# 費用対効果
        high_learning_rate = books[i,1:M+1]
        high_eff_price = books[i,0]		# 本の価格
        high_eff_idx = i			 	# 本のインデックス
    total_price += high_eff_price
    learning_rates += high_learning_rate
    if np.mean(learning_rates) >= X:
      break
    books = np.delete(books, high_eff_idx, axis=0)  # 抽出した本を除外
  print(total_price)

Submission status: Wrong Answer

Solution code:
blist = []
def createBitline(N, p, bl):
	if(N == p and len(bl) == N):
		blist.append(bl)
	else:
		createBitline(N, p + 1, bl + "0")
		createBitline(N, p + 1, bl + "1")

def checkClear(X, list):
	for i in range(1, len(list)):
		if int(list[i]) < X:
			return False
	return True

listCA = []
N,M,X = map(int, input().split())
for i in range(N):
	listCA.append(input().split())
for i in listCA:
	print(i)
createBitline(N, 0, "")
cost = []
for x in range(len(blist)):
	sumCA = [0] * (M + 1)
	for i in range(N):
		if blist[x][i] == "1":
			for j in range(len(listCA[i])):
				sumCA[j] += int(listCA[i][j])
	if checkClear(X, sumCA):
		cost.append(sumCA[0])
if cost:
	print(min(cost))
else:
	print('-1')

Submission status: Wrong Answer

Solution code:
kati_ok = list()
def katihantei(kati,ind,M,X,i):
    global kati_ok
    # print(ind)
    f = 0
    if(ind==M):
        return i
    if(kati[ind] < X):
        f = 1
    if(f == 1):
        return 
    ind+=1    
    return katihantei(kati,ind,M,X,i)


def main():
    N,M,X = map(int,input().split())
    diction = list()
    for i in range(N):
        list_i =[i]
        list_i.extend(list(map(int,input().split())))
        diction.append(list_i)
    # print(diction)

    n = len(diction)
    bit_list =list()
    for i in range(2 ** n):
        bit = []
        for j in range(n):  # このループが一番のポイント
            if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
                bit.append(diction[j][0])  # フラグが立っていたら bag に果物を詰める
        # print(bit)
        bit_list.append(bit)
    # print(bit_list)
    katiari = list()
    sum_kingaku = list()
    for i in range(len(bit_list)):
        kingaku = 0
        kati = [0]*M
        for j in range(len(bit_list[i])):
            kingaku += diction[bit_list[i][j]][1]
            for k in range(M):
                kati[k]+=diction[bit_list[i][j]][2+k]
        sum_kingaku.append(kingaku)
        
        sorenokati = katihantei(kati,0,M,X,i)
        if(sorenokati!=None):
            katiari.append(sorenokati)
    # print(katiari,sum_kingaku)
    if(len(katiari)==0):
        print(-1)
    else:
        min_kingaku = 10**5
        for i in range(len(katiari)):
            if(min_kingaku>sum_kingaku[katiari[i]]):
                min_kingaku = sum_kingaku[katiari[i]]
        print(min_kingaku)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
blist = []
def createBitline(N, p, bl):
	if(N == p and len(bl) == N):
		blist.append(bl)
	else:
		createBitline(N, p + 1, bl + "0")
		createBitline(N, p + 1, bl + "1")

# list内各項目が理解度Xに到達しているかチェック
# 引数(X, list)
def checkClear(X, list):
	for i in range(1, len(list)):
		if int(list[i]) < X:
			return False
	return True

listCA = []
def main3():
	N,M,X = map(int, input().split())
	for i in range(N):
		listCA.append(input().split())
	createBitline(N, 0, "")
	max = 10**5*12+1
	cost = []
	flg = False
	# ビット列パターン分繰り返す
	for x in range(len(blist)):
		sumCA = [0] * M
		# 入力各行を確認し、ビットに1が立っていれば、その行を加算する
		for i in range(N):
			if blist[x][i] == "1":
				for j in range(M):
					sumCA[j] += int(listCA[i][j])
		# 理解度Xを満たすかつ過去の金額より安い場合、値を更新する
		if checkClear(X, sumCA):
			cost.append(sumCA[0])
			flg = True
	if flg:
		print(min(cost))
	else:
		print('-1')
        
if __name__ == "__main__":

	main3()

Submission status: Wrong Answer

Solution code:
blist = []
def createBitline(N, p, bl):
	if(N == p and len(bl) == N):
		blist.append(bl)
	else:
		createBitline(N, p + 1, bl + "0")
		createBitline(N, p + 1, bl + "1")

def checkClear(X, list):
	for i in range(1, len(list)):
		if X > int(list[i]):
			return False
	return True

listCA = []
N,M,X = map(int, input().split())
for i in range(N):
	listCA.append(input().split())
createBitline(N, 0, "")
max = 10**5*12+1
flg = False
for x in range(len(blist)):
	sumCA = [0] * M
	for i in range(N):
		if blist[x][i] == "1":
			for j in range(M):
				sumCA[j] += int(listCA[i][j])
	if checkClear(X, sumCA) and sumCA[0] < max:
		max = sumCA[0]
		flg = True
if flg:
	print(max)
else:
	print('-1')

Submission status: Wrong Answer

Solution code:
blist = []
def createBitline(N, p, bl):
	if(N == p):
		blist.append(bl)
	else:
		createBitline(N, p + 1, bl + "0")
		createBitline(N, p + 1, bl + "1")

# list内各項目が理解度Xに到達しているかチェック
# 引数(X, list)
def checkClear(X, list):
	for i in range(1, len(list)):
		if X > int(list[i]):
			return False
	return True

listCA = []
def main3():
	N,M,X = map(int, input().split())
	for i in range(N):
		listCA.append(input().split())
	createBitline(N, 0, "")
	max = 100000000
	flg = False
	# ビット列パターン分繰り返す
	for x in range(2**N):
		sumCA = [0] * M
		# 入力各行を確認し、ビットに1が立っていれば、その行を加算する
		for i in range(N):
			if blist[x][i] == "1":
				for j in range(M):
					sumCA[j] += int(listCA[i][j])
		# 理解度Xを満たすかつ過去の金額より安い場合、値を更新する
		if checkClear(X, sumCA) and sumCA[0] < max:
			max = sumCA[0]
			flg = True
	if flg:
		print(max)
	else:
		print('-1')
if __name__ == "__main__":
	main3()

Submission status: Wrong Answer

Solution code:
blist = []
def createBitline(N, p, bl):
	if(N == p):
		blist.append(bl)
	else:
		createBitline(N, p + 1, bl + "0")
		createBitline(N, p + 1, bl + "1")

# list内各項目が理解度Xに到達しているかチェック
# 引数(X, list)
def checkClear(X, M, list):
	for i in range(1, M):
		if X > int(list[i]):
			return False
	return True

listCA = []
def main3():
	N,M,X = map(int, input().split())
	for i in range(N):
		listCA.append(input().split())
	createBitline(N, 0, "")
	max = 1000000000000
	flg = False
	# ビット列パターン分繰り返す
	for x in range(len(blist)):
		sumCA = [0] * M
		# 入力各行を確認し、ビットに1が立っていれば、その行を加算する
		for i in range(N):
			if blist[x][i] == "0":
				for j in range(M):
					sumCA[j] += int(listCA[i][j])
		# 理解度Xを満たすかつ過去の金額より安い場合、値を更新する
		if checkClear(X, M, sumCA) and sumCA[0] < max:
			max = sumCA[0]
			flg = True
	if flg:
		print(max)
	else:
		print("-1")    
if __name__ == "__main__":
	main3()

Submission status: Wrong Answer

Solution code:
blist = []
def createBitline(N, p, bl):
	if(N == p):
		blist.append(bl)
	else:
		createBitline(N, p + 1, bl + "0")
		createBitline(N, p + 1, bl + "1")

# list内各項目が理解度Xに到達しているかチェック
# 引数(X, list)
def checkClear(X, M, list):
	for i in range(1, M):
		if X > int(list[i]):
			return False
	return True

listCA = []
def main3():
	N,M,X = map(int, input().split())
	for i in range(N):
		listCA.append(input().split())
	createBitline(N, 0, "")
	max = 1000000000
	flg = False
	# ビット列パターン分繰り返す
	for x in range(len(blist)):
		sumCA = [0] * M
		# 入力各行を確認し、ビットに1が立っていれば、その行を加算する
		for i in range(N):
			if blist[x][i] == "0":
				for j in range(M):
					sumCA[j] += int(listCA[i][j])
		# 理解度Xを満たすかつ過去の金額より安い場合、値を更新する
		if checkClear(X, M, sumCA) and sumCA[0] < max:
			max = sumCA[0]
			flg = True
	if flg:
		print(max)
	else:
		print("-1")    
if __name__ == "__main__":
	main3()

Submission status: Wrong Answer

Solution code:
blist = []
def createBitline(N, p, bl):
	if(N == p):
		blist.append(bl)
	else:
		createBitline(N, p + 1, bl + "0")
		createBitline(N, p + 1, bl + "1")

# list内各項目が理解度Xに到達しているかチェック
# 引数(X, list)
def checkClear(X, M, list):
	for i in range(1, M):
		if X > int(list[i]):
			return False
	return True

listCA = []
def main3():
	N,M,X = map(int, input().split())
	for i in range(N):
		listCA.append(input().split())
	createBitline(N, 0, "")
	max = 1000000000
	flg = False
	# ビット列パターン分繰り返す
	for x in range(len(blist)):
		sumCA = [0] * M
		# 入力各行を確認し、ビットに1が立っていれば、その行を加算する
		for i in range(N):
			if blist[x][i] == "1":
				for j in range(M):
					sumCA[j] += int(listCA[i][j])
		# 理解度Xを満たすかつ過去の金額より安い場合、値を更新する
		if checkClear(X, M, sumCA) and sumCA[0] < max:
			max = sumCA[0]
			flg = True
	if flg:
		print(max)
	else:
		print("-1")

Submission status: Wrong Answer

Solution code:
blist = []
def createBitline(N, p, bl):
	if(N == p):
		blist.append(bl)
	else:
		createBitline(N, p + 1, bl + "0")
		createBitline(N, p + 1, bl + "1")

# list内各項目が理解度Xに到達しているかチェック
# 引数(X, list)
def checkClear(X, list):
	for i in range(1,len(list)):
		if int(list[i]) < X:
			return False
	return True

listCA = []
def main3():
	N,M,X = map(int, input().split())
	for i in range(N):
		listCA.append(input().split())
	createBitline(N, 0, "")
	max = 1000000000
	flg = False
	# ビット列パターン分繰り返す
	for x in range(len(blist)):
		sumCA = [0] * M
		# 入力各行を確認し、ビットに1が立っていれば、その行を加算する
		for i in range(N):
			if blist[x][i] == "1":
				for j in range(M):
					sumCA[j] += int(listCA[i][j])
		# 理解度Xを満たすかつ過去の金額より安い場合、値を更新する
		if checkClear(X, sumCA) and sumCA[0] < max:
			max = sumCA[0]
			flg = True
	if flg:
		print(max)
	else:
		print("-1")        
if __name__ == "__main__":
	main3()

Submission status: Wrong Answer

Solution code:
blist = []
def createBitline(N, p, bl):
	if(N == p):
		blist.append(bl)
	else:
		createBitline(N, p + 1, bl + "0")
		createBitline(N, p + 1, bl + "1")
 
def checkClear(X, list):
	for i in range(1,len(list)):
		if int(list[i]) < X:
			return False
	return True
 
listCA = []
N,M,X = map(int, input().split())
for i in range(N):
	listCA.append(input().split())
createBitline(N, 0, "")
max = 1000000000
for x in range(2**N):
	sumCA = [0] * M
	for i in range(N):
		if blist[x][i] == "1":
			for j in range(M):
				sumCA[j] += int(listCA[i][j])
	if checkClear(X, sumCA) and sumCA[0] < max:
		max = sumCA[0]
if max == 1000000000:
	print(-1)
else:
	print(max)

Submission status: Wrong Answer

Solution code:
blist = []
def createBitline(N, p, bl):
	if(N == p):
		blist.append(bl)
	else:
		createBitline(N, p + 1, bl + "0")
		createBitline(N, p + 1, bl + "1")

def checkClear(X, list):
	for i in range(1,len(list)):
		if int(list[i]) < X:
			return False
	return True

listCA = []
N,M,X = map(int, input().split())
for i in range(N):
	listCA.append(input().split())
createBitline(N, 0, "")
max = 10000000
for x in range(2**N):
	sumCA = [0] * M
	for i in range(N):
		if blist[x][i] == "1":
			for j in range(M):
				sumCA[j] += int(listCA[i][j])
	if checkClear(X, sumCA) and sumCA[0] < max:
		max = sumCA[0]
if max == 10000000:
	print(-1)
else:
	print(max)

Submission status: Wrong Answer

Solution code:
import numpy as np
n, m, x = map(int, input().split())
Book = [list(map(int, input().split())) for _ in range(n)]
select = [np.array([])]*(2**n)
cost = [0]*(2**n)
skill = [np.array([0]*m)]*(2**n)
cost2 = []
for i in range(2**n):
    for j in range(n):
        if (i >> j) & 1:
            cost[i] += Book[j][0]
            skill[i] += np.array(Book[j])[1:m+1]
    if np.min(skill[i]) >= x:
        cost2.append(cost[i])
if len(cost2) > 0:
    print(min(cost2))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools
n, m, x = [int(k) for k in input().split()]
c = np.zeros(n, dtype=int)
a = np.zeros((n, m), dtype=int)
for i in range(n):
    c[i], *a[i] = [int(k) for k in input().split()]
cost = np.sum(c) + 1
for nn in range(1,n+1):
    for k in itertools.combinations(np.argsort(c),nn):
        k = list(k)
        cs = sum(c[k].flatten())
        if cs > cost:
            break
        rikai_a = np.sum(a[k],axis=0)
        if np.all(rikai_a >= x):
            cost = min(cost,cs)
            break
if cost < np.sum(c) + 1:
    print(cost)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools
n, m, x = [int(k) for k in input().split()]
c = np.zeros(n, dtype=int)
a = np.zeros((n, m), dtype=int)
rikai_a = np.zeros(m, dtype=int)
bool_c = np.full(n, False)
for i in range(n):
    c[i], *a[i] = [int(k) for k in input().split()]
cost = np.sum(c) + 1
for nn in range(1,n+1):
    for k in itertools.combinations(np.argsort(c),nn):
        k = list(k)
        cs = sum(c[k].flatten())
        # if cs > cost:
        #     break
        rikai_a = np.sum(a[k],axis=0)
        if np.all(rikai_a >= x):
            cost = min(cost,cs)
            break
if cost < np.sum(c) + 1:
    print(cost)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools
n, m, x = [int(k) for k in input().split()]
c = np.zeros(n, dtype=int)
a = np.zeros((n, m), dtype=int)
rikai_a = np.zeros(m, dtype=int)
bool_c = np.full(n, False)
for i in range(n):
    c[i], *a[i] = [int(k) for k in input().split()]
cost = np.sum(c) + 1
for nn in range(1,n+1):
    for k in itertools.combinations(np.argsort(c),nn):
        k = list(k)
        cs = sum(c[k].flatten())
        if cs > cost:
            break
        rikai_a = np.sum(a[k],axis=0)
        if np.all(rikai_a >= x):
            cost = min(cost,cs)
            break
if cost < np.sum(c) + 1:
    print(cost)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools
n, m, x = [int(k) for k in input().split()]
c = np.zeros(n, dtype=int)
a = np.zeros((n, m), dtype=int)
rikai_a = np.zeros(m, dtype=int)
bool_c = np.full(n, False)
for i in range(n):
    c[i], *a[i] = [int(k) for k in input().split()]
cost = np.sum(c) + 1
for nn in range(1,n+1):
    for k in itertools.combinations(np.argsort(c),nn):
        k = list(k)
        cs = sum(c[k].flatten())
        if cs > cost:
            break
        print(cs)
        rikai_a = np.sum(a[k],axis=0)
        if np.all(rikai_a >= x):
            cost = min(cost,cs)
            break
if cost < np.sum(c) + 1:
    print(cost)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools
n, m, x = [int(k) for k in input().split()]
c = np.zeros(n, dtype=int)
a = np.zeros((n, m), dtype=int)
rikai_a = np.zeros(m, dtype=int)
bool_c = np.full(n, False)
for i in range(n):
    c[i], *a[i] = [int(k) for k in input().split()]
cost = np.sum(c) + 1
for nn in range(1,n+1):
    for k in itertools.combinations(np.argsort(c),nn):
        k = list(k)
        cs = np.sum(np.sum(c[k],axis=0))
        if cs > cost:
            break
        rikai_a = np.sum(a[k],axis=0)
        if np.all(rikai_a >= x):
            cost = min(cost,cs)
            break
if cost < np.sum(c) + 1:
    print(cost)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
from operator import add
n, m, x = map(int, input().split())
A = []

for i in range(n):
    A.append((list(map(int, input().split()))))

n = len(A)
ans = []

for j in range(2**n):
    buy = []
    skill = [0, 0, 0]
    total = 0
    for k in range(n):
        if(j >> k & 1):
            buy.append(A[k])
            total += A[k][0]
            skill = list(map(add, skill, A[k][1:]))
            if all(x <= e for e in skill):
                ans.append(total)

if len(ans):
    print(min(ans))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools
n, m, x = [int(k) for k in input().split()]
c = np.zeros(n, dtype=int)
a = np.zeros((n, m), dtype=int)
rikai_a = np.zeros(m, dtype=int)
bool_c = np.full(n, False)
finished = False
for i in range(n):
    c[i], *a[i] = [int(k) for k in input().split()]
cost = np.sum(c)
for nn in range(1,n+1):
    for k in [l for l in itertools.combinations(np.argsort(c),nn) if sum(c[list(l)]) < cost]:
        rikai_a = np.zeros(m, dtype=int)
        cs = 0
        for i in k:
            rikai_a += a[i]
            cs += c[i]
        if np.all(rikai_a >= x):
            finished = True
            cost = min(cost,cs)
            break
if finished:
    print(cost)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools
n, m, x = [int(k) for k in input().split()]
c = np.zeros(n, dtype=int)
a = np.zeros((n, m), dtype=int)
rikai_a = np.zeros(m, dtype=int)
bool_c = np.full(n, False)
finished = False
for i in range(n):
    c[i], *a[i] = [int(k) for k in input().split()]
cost = np.sum(c)
for nn in range(1,n+1):
    for k in [l for l in itertools.combinations(np.argsort(c),nn) if sum(l) < cost]:
        rikai_a = np.zeros(m, dtype=int)
        cs = 0
        for i in k:
            rikai_a += a[i]
            cs += c[i]
        if np.all(rikai_a >= x):
            finished = True
            cost = min(cost,cs)
            break
if finished:
    print(cost)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools
n, m, x = [int(k) for k in input().split()]
c = np.zeros(n, dtype=int)
a = np.zeros((n, m), dtype=int)
rikai_a = np.zeros(m, dtype=int)
bool_c = np.full(n, False)
finished = False
for i in range(n):
    c[i], *a[i] = [int(k) for k in input().split()]
cost = np.sum(c)
for nn in range(1,n+1):
    for k in itertools.combinations(np.argsort(c),nn):
        rikai_a = np.zeros(m, dtype=int)
        cs = 0
        for i in k:
            rikai_a += a[i]
            cs += c[i]
        if np.all(rikai_a >= x):
            finished = True
            cost = min(cost,cs)
            break
    else:
        continue
    break
if finished:
    print(cost)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
nmx = input('')
n = int(nmx.split(' ')[0])
m = int(nmx.split(' ')[1])
x = int(nmx.split(' ')[2])

clist=[]
alist=[]
for i in range(n):
    ca = input('')
    c = ca.split(' ')[0]
    clist.append(c)
    a = []
    for j in range(1,m+1):
        a.append(ca.split(' ')[j])
    alist.append(a)

min_price=99999999999
for i in range(2**n):
    skilllist=[0]*m
    buylist = [0]*n
    cost=0
    for j in range(n):
        if (i>>j )&1:
            buylist[j]=1
            cost+=int(clist[j])
            a = alist[j]
            for k in range(m):
                skilllist[k]+=int(a[k])

    ok = True
    for skill in skilllist:
        if skill < x:
            ok = False
    if ok and cost < min_price:
        min_price=cost
    print('{}:\\{} :{} ->{} [{}]'.format(i,cost,buylist,skilllist,min_price))
if min_price == 99999999999:
    min_price=-1
print(min_price)