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:
N, M, X = map(int, input().split())
#N=参考書の冊数, 縦,M＝学びたいアルゴリズムの数, 横,X＝目標の理解度
S = [ input().split() for _ in range(N)]
mintotal = 10 ** 9

for i in range(2 ** N):
    alg = [0 for _ in range(M)]
    #bag = []
    total = 0
    #print("pattern {}:".format(i),  end="")
    for j in range(N):
        if ((i >> j) & 1):
            #bag.append(S[j])
            for k in range(M):
                alg[k] += int(S[j][k + 1])
            total += int(S[j][0])
    #print(alg, bag)

    for l in range(M):
        #print(alg[l])
        if alg[l] < X:
            break
    else:
        mintotal = min(mintotal, total)

if mintotal == 10 ** 7:
    print(-1)
else:
    print(mintotal)

Submission status: Wrong Answer

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+1) for i in range(2**n)] 
#print(listA)
for i in range(2 ** n):
    for j in range(n):
        if((i >> j) & 1 ):
            for l in range(m+1):
                x[i][l] += listA[j][l]
            
#print(x)

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

Submission status: Wrong Answer

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+1) for i in range(2**n)] 
#print(listA)
for i in range(2 ** n):
    for j in range(n):
        if((i >> j) & 1 ):
            for l in range(m+1):
                x[i][l] += listA[j][l]
            
print(x)

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

Submission status: Wrong Answer

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+1) for i in range(2**n)] 
#print(listA)
for i in range(2 ** n):
    for j in range(n):
        if((i >> j) & 1 ):
            for l in range(m+1):
                x[i][l] += listA[j][l]
            
#print(x)

cnt = 10**9
t = [k] * (m+1)
#print(t)
for i in x:
    u = 0
    for j in range(1, m):
        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: Wrong Answer

Solution code:
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+1) for i in range(2**n)] 
#print(listA)
for i in range(2 ** n):
    for j in range(n):
        if((i >> j) & 1 ):
            for l in range(m+1):
                x[i][l] += listA[j][l]
            
print(x)

cnt = 10**9
t = [k] * (m+1)
print(t)
for i in x:
    u = 0
    for j in range(1, m):
        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: Wrong Answer

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(m):
        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: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
cm = []
llm = []
lf = []
for i in range(n):
    lm = [int(k) for k in input().split()]
    c = lm.pop(0)
    llm.append(lm)
    cm.append(c)
    lf.append(False)
mc = 1000000
fc = False
while True:
    #calc
    c = 0
    lx = [0 for j in range(m)]
    for i in range(n):
        if lf[i]:
            for j in range(m):
                lx[j] += llm[i][j]
            c += cm[i]
    fx = True
    for j in range(m):
        if lx[j] < x:
            fx = False
            break
    if fx:
        if mc > c:
            mc = c
            fc = True
    #next
    f = False
    for i in range(n):
        if f:
            break
        lf[i] = not lf[i]
        f = lf[i]
    if not f:
        break
if fc:
    print(mc)
else:
    print(-1)

Submission status: Wrong Answer

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**n):
    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: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
book_lists = [list(map(int, input().split())) for _ in range(N)]
ansbit = -1
cost = [0] * (2 ** N)
flag = 0

for i in range(2 ** N):
    R = [0] * M
    c = 0
    for j in range(M):
        if (i >> j) & 1:
            for index, m in enumerate(book_lists[j]):
                if index == 0:
                    c += m
                else:
                    R[index-1] += m

    if min(R) >= X:
        cost[i] = c
        flag = 1

if flag == 0:
    print(-1)
else:
    cost = [i for i in cost if i > 0]
    print(min(cost))

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
book_lists = [list(map(int, input().split())) for _ in range(N)]
ansbit = -1
cost = [0] * (2 ** N)
flag = 0

for i in range(2 ** N):
    R = [0] * M
    c = 0
    for j in range(M):
        if (i >> j) & 1:
            for index, m in enumerate(book_lists[j]):
                if index == 0:
                    c += m
                else:
                    R[index-1] += m

    if min(R) >= X:
        cost[i] = c
        flag = 1

if flag == 0:
    print(-1)
else:
    print(cost)
    print(R)
    cost = [i for i in cost if i > 0]
    print(cost)
    print(min(cost))









'''
def saiki(count,price,lis):
    if count==N:
        judge=True
        for item in lis:
            if item<X:
                judge=False
        if judge:
            ans.append(price)
    else:
        temp=[lis[i]+note[count][i+1] for i in range(M)]
        saiki(count+1,price,lis)
        saiki(count+1,price+note[count][0],temp)

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

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

ans=[]
saiki(0,0,[0]*M)

print(min(ans) if len(ans)!=0 else -1)
'''

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
import copy

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

b = []
for i in range(n):
    b.append(tuple(map(int, input().split())))


bss = [[ 0 for i in range(m + 1)]]
mc = -1

for i in range(n):
    nbss = copy.copy(bss)
    for bs in bss:
        #print(bs, b[i])
        nbs = list(map(lambda x, y: x + y, bs, b[i]))
        for j in range(1, m):
            if nbs[j] < x:
                nbss.append(nbs)
                break
        else:
            if mc < 0:
                mc = nbs[0]
            else:
                mc = min(mc, nbs[0])
                
    bss = nbss

print(mc)

Submission status: Wrong Answer

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(N**2):
    ruikei=[0]*M
    onedan=0
    for j in range(N):
        if ((i>>j)&1):
            onedan+=CA[j][0]
            for k in range(1,M+1):
                ruikei[k-1]+=CA[j][k]
    #print(onedan)
    #print(ruikei)    
    kari=True    
    for j in ruikei:
        if j<X:
            kari=False
    if kari:
        ans=min(ans,onedan)
if ans==float("inf"):
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

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(N**2):
    ruikei=[0]*M
    onedan=0
    for j in range(N):
        if ((i>>j)&1):
            onedan+=CA[j][0]
            for k in range(1,M+1):
                ruikei[k-1]+=CA[j][k]
    #print(onedan)
    #print(ruikei)        
    if min(ruikei)>=X:
        ans=min(onedan,ans)
if ans==float("inf"):
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
N,M,X=map(int,input().split())
CA=[list(map(int,input().split())) for i in range(N)]
ans=10**16
for i in range(N**2):
    ruikei=[0]*M
    onedan=0
    for j in range(N):
        if ((i>>j)&1):
            onedan+=CA[j][0]
            for k in range(1,M+1):
                ruikei[k-1]+=CA[j][k]
    #print(onedan)
    #print(ruikei)        
    if min(ruikei)>=X:
        ans=min(onedan,ans)
if ans==10**16:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
N,M,X=map(int,input().split())
CA=[list(map(int,input().split())) for i in range(N)]
ans=10**16
for i in range(N**2):
    ruikei=[0]*M
    onedan=0
    for j in range(N):
        if ((i>>j)&1):
            onedan+=CA[j][0]
            for k in range(1,M+1):
                ruikei[k-1]+=CA[j][k]
    #print(onedan)
    #print(ruikei)        
    if min(ruikei)>=X:
        ans=min(onedan,ans)
if ans<10**16:
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

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

ans = 10 ** 10

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

C = []
A = [[]] * N

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

for i in range(2 ** N - 1):
    tans = 0
    tA = [0] * M
    for j in range(N):
        if i & (1 << j):
            tans += C[j]
            for k in range(M):
                tA[k] += A[j][k]

    flag = True
    for k in range(M):
        flag &= (tA[k] >= X)

    #print(i, tA, tans)

    if flag:
        ans = min(ans, tans)

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

Submission status: Wrong Answer

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

ans = 10 ** 20

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

C = []
A = [[]] * N

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

for i in range(2 ** N - 1):
    tans = 0
    tA = [0] * M
    for j in range(N):
        if i & (1 << j):
            tans += C[j]
            for k in range(M):
                tA[k] += A[j][k]

    flag = True
    for k in range(M):
        flag &= (tA[k] >= X)

    #print(i, tA, tans)

    if flag:
        ans = min(ans, tans)

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

Submission status: Wrong Answer

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

ans = 10 ** 10

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

C = []
A = [[]] * N

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

for i in range(2 ** N - 1):
    tans = 0
    tA = [0] * M
    for j in range(N):
        if i & (1 << j):
            tans += C[j]
            for k in range(M):
                tA[k] += A[j][k]

    flag = True
    for k in range(M):
        flag &= (tA[k] >= X)

    #print(i, tA, tans)

    if flag:
        ans = min(ans, tans)

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

Submission status: Wrong Answer

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

CA = []
for i in range(N):
    CA.append([int(j) for j in input().split()])

min_money = 100000 ** N
for i in range(2**N):
    money = 0
    result = [0] * M
    for j in range(N):
        if ((i >> j) & 1):
            money += CA[j][0]
            for n in range(1, M+1):
                result[n-1] += CA[j][n]
    if money < min_money and min(result) >= X:
        min_money = money

print(min_money if min_money != 100000 ** N else -1)

Submission status: Wrong Answer

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

# 参考書の選択パターン作成
patterns=[]
for i in range(n):
    patterns.append(itertools.combinations(tmp,i+1))

# 全ての参考書を購入しても条件を満たせないときは-1
for arg in range(m):
    point=0
    for book in books:
        point+=book[arg+1]
    if point<x:
        print(-1)
        exit()

# すべての参考書のパターン
for pattern in patterns:
    # ある参考書のパターン
    for bks in pattern:
        flg=True
        # 各アルゴリズムの時の理解度合計
        point=0
        for i in range(m):
            # あるアルゴリズムのときの点数とトータルコスト
            cost=0
            for bk in bks:
                cost+=books[bk][0]
                point+=books[bk][i+1]
            if point < x:
                # あるアルゴリズムで条件を満たさない
                flg=False
        if flg==True:
            result.append(cost)
print(min(result))

Submission status: Wrong Answer

Solution code:
N,M,X=map(int,input().split())
CA=[list(map(int,input().split())) for i in range(N)]
ans=0
for i in range(N**2):
    ruikei=[0]*M
    onedan=0
    for j in range(N):
        if ((i>>j)&1):
            onedan+=CA[j][0]
            for k in range(1,M+1):
                ruikei[k-1]+=CA[j][k]
    #print(onedan)
    #print(ruikei)        
    if min(ruikei)>=X:
        print(onedan)
        exit()
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
N,M,X=map(int,input().split())
CA=[list(map(int,input().split())) for i in range(N)]
ans=10**8
for i in range(N**2):
    ruikei=[0]*M
    onedan=0
    for j in range(N):
        if ((i>>j)&1):
            onedan+=CA[j][0]
            for k in range(1,M+1):
                ruikei[k-1]+=CA[j][k]
    #print(onedan)
    #print(ruikei)        
    if min(ruikei)>=X:
        ans=min(onedan,ans)
if ans!=10**8:
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
N,M,X=map(int,input().split())
CA=[list(map(int,input().split())) for i in range(N)]
ans=1145141919810
for i in range(N**2):
    ruikei=[0]*M
    onedan=0
    for j in range(N):
        if ((i>>j)&1):
            onedan+=CA[j][0]
            for k in range(1,M+1):
                ruikei[k-1]+=CA[j][k]
    #print(onedan)
    #print(ruikei)        
    if min(ruikei)>=X:
        ans=min(onedan,ans)
if ans!=1145141919810:
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

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(M):
    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(ans,money)

if ans==float('inf'):
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

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):
  money=0
  rikaido=[0]*M
  for j in range(M):
    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(ans,money)

if ans==float('inf'):
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]
ans = 10**6
ok = False
for i in range(2**n):
    y = [0]*(m+1)
    for j in range(n+1):
        if i & (1 << j):
            for k in range(m+1):
                y[k] = y[k] + ca[j][k]
    if sum(z >= x for z in y[1:]) == m:
        ans = min(ans, y[0])
        ok = True
if ok:
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]
ans = 10**6
ok = False
for i in range(2**n):
    y = [0]*(m+1)
    for j in range(n):
        if i & (1 << j):
            for k in range(m+1):
                y[k] = y[k] + ca[j][k]
    if sum(z >= x for z in y[1:]) == m:
        ans = min(ans, y[0])
        ok = True
if ok:
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    [n,m,x] = [int(i) for i in input().split()]
    l = []
    for i in range(n):
        l.append([int(j) for j in input().split()])
    # print(l)
    t= []
    for i in range(m+1):
        t.append(0)
    for i in range(n):
        for j in range(m+1):
            t[j] += l[i][j]
    
    for i in range(1,m+1,1):
        if t[i] < x:
            print('-1')
            exit()
    
    l.sort(key = lambda x: x[0],reverse = True) 
    for i in range(n):
        pos = True
        for j in range(1,m+1):
            if t[j] - l[i][j] < x:
                pos = False
                break
        if pos:
            for j in range(0,m+1):
                t[j] -= l[i][j]
    print(t[0])

Submission status: Wrong Answer

Solution code:
import numpy as np

n, m, x = map(int, input().split(' '))
a = np.zeros([n, m])
c = np.zeros(n)

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

INF = 10000000000000000
ans = INF

for i in range(1<<n):
  skill = np.zeros(m)
  cost = 0
  for j in range(n):
    if i & (1<<j):
      cost += c[j]
      skill += a[j]
  if all(skill >= x):
    ans = min(ans, cost)

print(ans if ans != INF else -1)

Submission status: Wrong Answer

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):
            for j in range(M):
                X_[j] += Aij[i][j] * candidate[i]
                cost += Ci[i] * candidate[i]
        if min(X_) >= X:
            ans.append(cost)
        return

    for bit in range(0):
        dfs(candidate + [bit])



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

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
from itertools import product

n, m, x = map(int, input().split())
c = []
A = []

ans = 10**9

products = list(product([0,1], repeat=n))

for _ in range(n):
    c_a = list(map(int, input().split()))
    c.append(c_a[0])
    A.append(c_a[1:])

min_price = 10**9

for p in products:
    sum_alg = [0]*m
    price = 0
    for i, pp in enumerate(p):
        if pp == 1:
            for j in range(m):
                sum_alg[j] += A[i][j]
            price += c[i]

    if min(sum_alg) > x: 
        min_price = min(price, min_price)


if min_price == 10**9:
    print(-1)
else:
    print(min_price)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
from itertools import product

n, m, x = map(int, input().split())
c = []
A = []

ans = 10**9

products = list(product([0,1], repeat=n))

for _ in range(n):
    c_a = list(map(int, input().split()))
    c.append(c_a[0])
    A.append(c_a[1:])

min_price = 10**9

for p in products:
    sum_alg = [0]*m
    price = 0
    for i, pp in enumerate(p):
        if pp == 1:
            for j in range(m):
                sum_alg[j] += A[i][j]
            price += c[i]

    if sum_alg > [x] * m and price < min_price: 
        min_price = price


if min_price == 10**9:
    print(-1)
else:
    print(min_price)

Submission status: Wrong Answer

Solution code:
def dfs(i, count, res):
    global ans
    if i == n:
        if min(count) < x:
            return False
        ans = min(ans, res)
        return ans
    else:
        dfs(i+1, count, res)
        dfs(i+1, [count[k-1] + l[i][k] for k in range(1, m+1)], res + l[i][0])


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

ans = 10 ** 9
dfs(0, [0] * m, 0)

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

Submission status: Wrong Answer

Solution code:
def dfs(i, count, res):
    global ans
    if i == n:
        for j in range(m):
            if count[j] < x:
                return 0
        ans = min(ans, res)
        return ans
    else:
        dfs(i+1, count, res)
        dfs(i+1, [count[k-1] + l[i][k] for k in range(1, m+1)], res + l[i][0])


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

ans = 10 ** 9

dfs(0, [0] * m, 0)

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

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
ca = [list(map(int,input().split())) for i in range(n)]
mincost = 10**111
count = 0

for i in range(2**n):
  li = [0]*m
  cost = 0
  count = 0
  for j in range(n):
    if (i >> j) & 1:
      cost += ca[j][0]
      for k in range(m):
        li[k] += ca[j][k]
  for l in range(m):
    if li[l] >= x:
      count += 1
  if count == m:
    mincost = min(cost,mincost)
    
if mincost == 10**111:
  print(-1)
else:
  print(mincost)

Submission status: Wrong Answer

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

Solution code:
import sys
from itertools import combinations
from collections import Counter
ct = Counter()
Ass = []
ans = []
N, M, X = map(int, input().split())
for i in range(N):
	Ass.append(list(map(int, input().split())))

for z in range(M):	
	B = []
	for i in range(N):
		B.append(Ass[i][z])
	D = []
	for i in range(1, N+1):
		for j in combinations(Ass, i):
			flag = True
			d = [0]*(M+1)
			for k in j:  # (2, 7, 3)
				for l in range(M+1):
					d[l] += k[l]
			for x in range(M+1):
				if d[x] >= X:
					pass
				else:
					flag=False
					break
			if flag:
				ans.append(d[0])

if len(ans) > 0:
	print(min(ans))
else:
	print('-1')

Submission status: Wrong Answer

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

matrix=[]

for _ in range(N):
    array=list(map(int,input().split()))
    matrix.append(array)

buy=[[0 for i in range(N)] for j in range(2**N)]
prices=[]

for i in range(2**N):
    num=i
    for j in range(N):
        dicit=2**(N-1-j)
        buy[i][j]=int(num/dicit)
        if num>=dicit:
            num=int(num-dicit)

for i in range(2**N):
    array=[]
    for j in range(M+1):
        NUMBER=sum([int(matrix[k][j]*buy[i][k]) for k in range(N)])
        array.append(NUMBER)
    prices.append(array)

judge=[]
for i in range(len(prices)):
    flg=True
    for j in range(1,M+1):
        if X>prices[i][j]:
            flg=False
    judge.append(flg)

min=10**5
for i in range(len(judge)):
    if judge[i]==True:
        if min>prices[i][0]:
            min=prices[i][0]
if(min==10**5):
    print(-1)
else:
    print(min)

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 = 10**5 * 12
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+1]
    if min(SCORE)>=X:
        ANS=min(ANS,MONEY)
if ANS == 10**5 * 12:
    print(-1)
else:
    print(ANS)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
import numpy as np
N, M, X = map(int, input().split())
xx = np.array([X for _ in range(M)])

C = {}
costs = []
for _ in range(N):
    c, *A = map(int, input().split())
    C[c] = A
    costs.append(c)
ans = 10**15
for i in range(0, N+1):
    for comb in combinations(costs, i):
        tmp = 0
        x = xx.copy()
        for cost in comb:
            tmp += cost
            x -= np.array(C[cost])
        if len(x[x <= 0]) >= M:
            ans = min(ans, tmp)

if ans == 10**15:
    ans = '-1'
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
import numpy as np
N, M, X = map(int, input().split())
xx = np.array([X for _ in range(M)])

C = {}
costs = []
for _ in range(N):
    c, *A = map(int, input().split())
    C[c] = A
    costs.append(c)
ans = 10**12
for i in range(0, N+1):
    for comb in combinations(costs, i):
        tmp = 0
        x = xx.copy()
        for cost in comb:
            tmp += cost
            x -= np.array(C[cost])
        if len(x[x <= 0]) >= M:
            ans = min(ans, tmp)

if ans == 10**12:
    ans = '-1'
print(ans)

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 = []
c = []
suit =[]
for i in range(M+1):
    a.append(0)
    
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):
            
            a[i] += L[x+y-1][i]
            
       
        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):
   
    if x + y <= N:
        print(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 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:
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 = []
c = []
suit =[]
for i in range(M+1):
    a.append(0)
    
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):
            
            a[i] += L[x+y-1][i]
            
       
        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):
   
    if x + y <= N:
        print(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 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(suit)
print(price)