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())
lvl = []
books = [list(map(int,input().split())) for i in range(N)]
books.sort(key = lambda x: sum(x[1:M])/x[0], reverse = True)
total_cost = 0

for book_num in range(len(books)):
    if book_num == 0:
        for i in range(M):
            lvl.append(0)
    if min(lvl) >= X:
            break
    total_cost += books[book_num][0]
    for i in range(M):
        lvl[i] += books[book_num][i+1]
                  
if min(lvl) < X:
    print(-1)
else:
    print(total_cost)

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
lvl = []
books = [list(map(int,input().split())) for i in range(N)]
books.sort(key = lambda x: sum(x[1:M])/x[0], reverse = True)
total_cost = 0
print(books)
for book_num in range(len(books)):
    if book_num == 0:
        for i in range(M):
            lvl.append(0)
    if min(lvl) >= X:
            break
    total_cost += books[book_num][0]
    for i in range(M):
        lvl[i] += books[book_num][i+1]
                  
if min(lvl) < X:
    print(-1)
else:
    print(total_cost)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
s = list(map(int, input().split()))
n = s[0]
m = s[1]
x = s[2]
book = []

for i in range(n):
    s = list(map(int, input().split()))
    book.append(s)
book=np.array(book)
ans=math.inf

for i in range(1<<n):

    skill = [0]*(m+1)
    for j in range(n):
        if i>>j & 1:
            for k,l in enumerate(book[j]):
                skill[k]+=l

    ok=1
    for j in range(1,m):
        if skill[j]<x :
            ok=0
            break
    if ok==1:
        ans=min(ans,skill[0])
if ans==math.inf:
    ans=-1
print(ans)

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
ans = float('Inf')
for i in range(2 ** n):
    sum_ = [0] * m
    cost = 0
    for j in range(n):
        #sum_ = [0] * m
        if ((i >> j) & 1):
            cost += a[j][0]
            for k in range(m):
                sum_[k] += a[j][k]
                
    flag = True
    for j in range(m):
        if sum_[j] < x:
            flag = False
    if flag:
        ans = min(ans, cost)
if ans == float('Inf'):
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import copy

def main() :
    inp1 = list(map(int,input().split()))
    inp2 = []
    exp  = []
    cost = 9999999

    for i in range(inp1[0]) :
        tmp = list(map(int,input().split()))
        inp2.append(tmp)

    for k in range(inp1[1]+1) :
        exp.append(0)

    for n in range(inp1[0]):
        cost = judge_method(exp, inp1, inp2, n, cost)

    if cost == 9999999 :
        print(-1)
    else :
        print(cost)

def judge_method(exp, inp1, inp2, n, cost) :
    for itr in range(n, inp1[0]) :
        judge = True
        temp = copy.copy(exp)
        for m in range(inp1[1]+1) :
            temp[m] = exp[m] + inp2[itr][m]
            #print(m, temp[m])
            if m != 0 :
                if temp[m] < inp1[2] :
                    judge = False
        if judge :
            if cost > temp[0] :
                cost = temp[0]
        if itr < (inp1[1] -1) :
            cost = judge_method(temp, inp1, inp2, itr+1, cost)

    return cost

if __name__ == '__main__' :
    main()

Submission status: Wrong Answer

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

total = 0
result = 1000000
count = 0
flag = True

#print(c_A)
for i in range(2** N):#行
    total = 0
    count = 0
    bit = [0]*N#行
    for j in range(N):#行
        state = [0] * M#列
        if (i >> j) & 1:
            bit[j] = 1
    
    #1の時全てのANを足し合わせる。合計金額を出す
    for k in range(N):
        if bit[k] == 1:
            #print(bit)
            for l in range(M):
                state[l] += c_A[k][l+1]
            total += c_A[k][0]
       
    for m in range(M):
        if state[m] < X:
            break
        else:
            count += 1
    #print(count)
    if count == M:
        flag = False
        result = min(total,result)
if flag == False:
    print(result)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import copy

def main() :
    inp1 = list(map(int,input().split()))
    inp2 = []
    exp  = []
    cost = 999999

    for i in range(inp1[0]) :
        tmp = list(map(int,input().split()))
        inp2.append(tmp)

    for k in range(inp1[1]+1) :
        exp.append(0)

    for n in range(inp1[0]):
        cost = judge_method(exp, inp1, inp2, n, cost)

    if cost == 999999 :
        print(-1)
    else :
        print(cost)

def judge_method(exp, inp1, inp2, n, cost) :
    for itr in range(n, inp1[0]) :
        judge = True
        temp = copy.copy(exp)
        for m in range(inp1[1]+1) :
            temp[m] = exp[m] + inp2[itr][m]
            #print(m, temp[m])
            if m != 0 :
                if temp[m] < inp1[2] :
                    judge = False
        if judge :
            if cost > temp[0] :
                cost = temp[0]
        if itr < (inp1[1] -1) :
            cost = judge_method(temp, inp1, inp2, itr+1, cost)

    return cost

if __name__ == '__main__' :
    main()

Submission status: Wrong Answer

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

total = 0
result = 1000000
count = 0
flag = True

#print(c_A)
for i in range(2** N):#行
    total = 0
    bit = [0]*N#行
    for j in range(N):#行
        state = [0] * M#列
        if (i >> j) & 1:
            bit[j] = 1
    
    #1の時全てのANを足し合わせる。合計金額を出す
    for k in range(N):
        if bit[k] == 1:
            #print(bit)
            for l in range(M):
                state[l] += c_A[k][l+1]
            total += c_A[k][0]
        #print(total)
    #print()
    #print(state)
    #print(total)
    for m in range(M):
        if state[m] < X:
            break
        else:
            count += 1
    #print(count)
    if count == M:
        flag = False
        result = min(total,result)
        count = 0
    count = 0
if flag == False:
    print(result)
else:
    print(-1)

Submission status: Wrong Answer

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

p = []

for i in range(1, 2**N):
    buff = [0] * M

    for j in range(N):
        if i >> j & 1:
            buff = [a + b for a, b in zip(buff, books[j])]

    for a in buff[1:]:
        if a < X:
            break
    else:
        p.append(buff[0])

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

print(ans)

Submission status: Wrong Answer

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

p = []

for i in range(1, 2**N):
    buff = [0, 0, 0, 0]

    for j in range(N):
        if i >> j & 1:
            buff = [a + b for a, b in zip(buff, books[j])]

    for a in buff[1:]:
        if a < X:
            break
    else:
        p.append(buff[0])

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

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools
n,m,x=map(int,input().split())
a=[]
for i in range(n):
    a.append(list(map(int,input().split())))
# a.sort()

result = []

for n in range(1,len(a)+1):
    for conb in itertools.combinations(a, n):
        result.append(np.array(conb)) #タプルをリスト型に変換

count = 0

ans = []

for i in range(len(result)):
    t = sum(result[i])
    print(t)
    for k in range(1,len(t)):
        print(t[k])
        if t[k] >= x:
            count += 1
        else:
            count = 0
            break
    if count == m:
        ans.append(t[0])
        count = 0
        
    
if len(ans) > 0:
    print(ans)
    
    print(min(ans))
    
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools
n,m,x=map(int,input().split())
a=[]
for i in range(n):
    a.append(list(map(int,input().split())))
a.sort()

# print(sum(al))
b = [0]*m
bl = np.array([b])
# print(bl)
# print(al)

result = []

for n in range(1,len(a)+1):
    for conb in itertools.combinations(a, n):
        result.append(np.array(conb)) #タプルをリスト型に変換
# print(result)

count = 0

ans = []

for i in range(len(result)):
    t = sum(result[i])
    for k in range(1,len(t)):
        if t[k] >= x:
            count += 1
        else:
            count = 0
            break
    if count == m:
        ans.append(t[0])
    
if len(ans) > 0:
    
    print(min(ans))
    
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n,m,x=(int(i) for i in input().split())
a=[]
c=[]
for i in range(n):
  a.append(list(map(int,input().split())))
  c.append(a[i][0])
  del a[i][0]
  
INF=1001001001
ans=INF

for s in range(1<<n):
  cost=0
  d=[0]*m
  for i in range(n):
    if(s>>i&1):
      cost+=c[i]
      for j in range(m):
        d[j]+=a[i][j]
  ok=True
  for j in range(m):
    if(d[j]<x):
      ok=False
    if ok:
      ans=min(ans,cost)
if ans==INF:
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools
n,m,x=map(int,input().split())
a=[]
for i in range(n):
    a.append(list(map(int,input().split())))
a.sort()

# print(sum(al))
b = [0]*m
bl = np.array([b])
# print(bl)
# print(al)

result = []

for n in range(1,len(a)+1):
    for conb in itertools.combinations(a, n):
        result.append(np.array(conb)) #タプルをリスト型に変換
# print(result)

count = 0

for i in range(len(result)):
    t = sum(result[i])
    # print(t)
    for k in range(1,len(t)):
        if t[k] >= x:
            count += 1
        else:
            count = 0
            break
    if count == m:
        break
if count == m:
    
    print(t[0])
    
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools
n,m,x=map(int,input().split())
a=[]
for i in range(n):
    a.append(list(map(int,input().split())))
a.sort()

# print(sum(al))
b = [0]*m
bl = np.array([b])
# print(bl)
# print(al)

result = []

for n in range(1,len(a)+1):
    for conb in itertools.combinations(a, n):
        result.append(np.array(conb)) #タプルをリスト型に変換
# print(result)

count = 0

for i in range(len(result)):
    t = sum(result[i])
    # print(t)
    for k in range(1,len(t)):
        if t[k] >= x:
            count += 1
        else:
            count = 0
            break
    if count == m:
        break
    
print(t[0])

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M,X = map(int,input().split())
CA = np.zeros((N,M+1))
C = [0] * N
A = np.zeros((N,M))
# C = [0]*N
# A = []
# CA = []
for i in range(N):
    # C[i] = map(int,input().split())
    # for j range(M):
    #     CA[i][j] = map(int,input().split())

    CA[i][:] = list(map(int,input().split())) # --これ正解
    #C[i],A[i][:] = list(map(int,input().split())) # できない


#print(CA)
# print(np.min(CA,axis=0)) # これで一番安い参考書情報取得できる
# print(CA[:,0]) #これで列取得
C = CA[:,0] # これで縦のN次元リスト取得できる
AA = CA[:,1:] # これでAの部分の行列（二次元配列）が取得できる
#print(AA)
#print(C)
#print(min(C))

# -- ans---
# 全探索でできる

# for i in range(N):
#     bit = bin(1<<i) # 取りうる全てのパターン
#     print(bin(1<<i))

INF = int(1001001001)
ans = INF
for i in range(2**len(C)): # 2**nパターン考えられる
    buy = []
    cost = 0
    d = [0]*M #理解度を格納するリスト
    for j in range(N):
        # 順に右シフトさせ最下位bitのチェックを行う
        # 10進のまま書いてもビット演算すると2進として計算してくれる！
        if ((i>>j) & 1): 
            buy.append(C[j])
            cost += C[j] # 価格を足す
            for k in range(M): # 買った参考書の理解度を足す
                d[k] += AA[j][k]
    #print(buy) # 上手く全パターン取得できた
    # 理解度の合計を計算
    flag = True
    for l in range(M):
        #print(d[l])
        if d[l] < X:
            flag = False
        if flag:
            ans = min(ans,cost)

if ans == INF :
    print("-1")
else:
    print(str(int(ans)))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M,X = map(int,input().split())
CA = np.zeros((N,M+1))
C = [0] * N
A = np.zeros((N,M))
# C = [0]*N
# A = []
# CA = []
for i in range(N):
    # C[i] = map(int,input().split())
    # for j range(M):
    #     CA[i][j] = map(int,input().split())

    CA[i][:] = list(map(int,input().split())) # --これ正解
    #C[i],A[i][:] = list(map(int,input().split())) # できない


#print(CA)
# print(np.min(CA,axis=0)) # これで一番安い参考書情報取得できる
# print(CA[:,0]) #これで列取得
C = CA[:,0] # これで縦のN次元リスト取得できる
AA = CA[:,1:] # これでAの部分の行列（二次元配列）が取得できる
#print(AA)
#print(C)
#print(min(C))

# -- ans---
# 全探索でできる

# for i in range(N):
#     bit = bin(1<<i) # 取りうる全てのパターン
#     print(bin(1<<i))

INF = int(1001001001)
ans = INF
for i in range(2**len(C)): # 2**nパターン考えられる
    buy = []
    cost = 0
    d = [0]*M #理解度を格納するリスト
    for j in range(N):
        # 順に右シフトさせ最下位bitのチェックを行う
        # 10進のまま書いてもビット演算すると2進として計算してくれる！
        if ((i>>j) & 1): 
            buy.append(C[j])
            cost += C[j] # 価格を足す
            for k in range(M): # 買った参考書の理解度を足す
                d[k] += AA[j][k]
    #print(buy) # 上手く全パターン取得できた
    # 理解度の合計を計算
    flag = True
    for l in range(M):
        #print(d[l])
        if d[l] < X:
            flag = False
        if flag:
            ans = min(ans,cost)

if ans == INF :
    print("-1")
else:
    print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M,X = map(int,input().split())
CA = np.zeros((N,M+1))
C = [0] * N
A = np.zeros((N,M))
# C = [0]*N
# A = []
# CA = []
for i in range(N):
    # C[i] = map(int,input().split())
    # for j range(M):
    #     CA[i][j] = map(int,input().split())

    CA[i][:] = list(map(int,input().split())) # --これ正解
    #C[i],A[i][:] = list(map(int,input().split())) # できない


#print(CA)
# print(np.min(CA,axis=0)) # これで一番安い参考書情報取得できる
# print(CA[:,0]) #これで列取得
C = CA[:,0] # これで縦のN次元リスト取得できる
AA = CA[:,1:] # これでAの部分の行列（二次元配列）が取得できる
#print(AA)
#print(C)
#print(min(C))

# -- ans---
# 全探索でできる

# for i in range(N):
#     bit = bin(1<<i) # 取りうる全てのパターン
#     print(bin(1<<i))

INF = int(1001001001)
ans = INF
for i in range(2**len(C)): # 2**nパターン考えられる
    buy = []
    cost = 0
    d = [0]*M #理解度を格納するリスト
    for j in range(N):
        # 順に右シフトさせ最下位bitのチェックを行う
        # 10進のまま書いてもビット演算すると2進として計算してくれる！
        if ((i>>j) & 1): 
            buy.append(C[j])
            cost += C[j] # 価格を足す
            for k in range(M): # 買った参考書の理解度を足す
                d[k] += AA[j][k]
    #print(buy) # 上手く全パターン取得できた
    # 理解度の合計を計算
    flag = True
    for l in range(M):
        #print(d[l])
        if d[l] < X:
            flag = False
        if flag:
            ans = min(ans,cost)

if ans == INF :
    print(-1)
else:
    print(int(ans))

Submission status: Wrong Answer

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

N, M, X = map(int, input().split())
pricelist = [0] * N
matrix = [[0] * M for _ in range(N)]
for i in range(N):
    row = list(map(int, input().split()))
    pricelist[i] = row.pop(0)
    matrix[i] = row

mintotalprice = 10**5 * 12 + 1
for bit in range(N**2):
    flag = True
    for j in range(M):
        totalscore = 0
        for i in range(N):
            if (bit>>i & 1) == 1:
                totalscore += matrix[i][j]
        if totalscore < X:
            flag = False
            break
    if flag:
        totalprice = 0
        for i in range(N):
            if (bit>>i & 1) == 1:
                totalprice += pricelist[i]
        mintotalprice = totalprice if mintotalprice > totalprice else mintotalprice
        
print(mintotalprice if mintotalprice != 10**5 * 12 + 1 else -1)

Submission status: Wrong Answer

Solution code:
def task(n, m, x, c, a):
    mx = [0] * m
    for i in range(0, n):
        for j in range(0, m):
            mx[j] += a[i][j]

    for j in range(0, m):
        if mx[j] < x:
            print(-1)
            return

    states = [0] * m

    best = 1000000
    for i in range(1, (2**n) + 1):
        price = 0
        for k in range(0, m):
            states[k] = 0
        for j in range(0, n):
            if ((i >> j) & 1):
                price += c[j]
                for k in range(0, m):
                    states[k] += a[j][k]

        if price < best:
            found = True
            for k in range(0, m):
                if states[k] < x:
                    found = False
                    break

            if found:
                best = price

    print(best)


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

task(n, m, x, c, a)

Submission status: Wrong Answer

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

N, M, X = map(int, input().split())
pricelist = [0] * N
matrix = [[0] * M for _ in range(N)]
for i in range(N):
    row = list(map(int, input().split()))
    pricelist[i] = row.pop(0)
    matrix[i] = row

mintotalprice = 10**5 * 12
for bit in range(N**2):
    flag = True
    for j in range(M):
        totalscore = 0
        for i in range(N):
            if (bit>>i & 1) == 1:
                totalscore += matrix[i][j]
        if totalscore < X:
            flag = False
            break
    if flag:
        totalprice = 0
        for i in range(N):
            if (bit>>i & 1) == 1:
                totalprice += pricelist[i]
        mintotalprice = totalprice if mintotalprice > totalprice else mintotalprice
        
print(mintotalprice if mintotalprice != 10**5 * 12 else -1)

Submission status: Wrong Answer

Solution code:
from sys import stdin, stdout
import math,sys
from itertools import permutations, combinations
from collections import defaultdict,deque,OrderedDict
import bisect as bi
import heapq 

'''
#------------------PYPY FAst I/o--------------------------------#
 
def I():return (int(stdin.readline()))
def In():return(map(int,stdin.readline().split()))
'''
#------------------Sublime--------------------------------------#
 
#sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');
def I():return (int(input()))
def In():return(map(int,input().split()))



def main():
    try:
        n,b,c=In()
        l=[]
        ratio=[]
        for i in range(n):
            temp=list(In())

            price=temp[0]
            rot=(sum(temp)-price)/price
            ratio.append((rot,i))
            l.append(temp)
        
        ratio.sort(key=lambda x:x[0],reverse=True)
        
        q=0
        marks=[0]*b
        i=0
        ans=0
        while q==0 and i<n:
            temp=l[ratio[i][1]]
            ans+=temp.pop(0)

            for x in range(b):
                marks[x]+=temp[x]

            if min(marks)>=c:
                q=1
                break
            i+=1
            #print(marks)
        if q==0:
            print(-1)
        else:
            print(ans)
    except:
        pass
        
M = 998244353
P = 1000000007
 
if __name__ == '__main__':
    for _ in range(1):
        main()

Submission status: Wrong Answer

Solution code:
import numpy as np
from itertools import product

def readlines(n):
    for _ in range(n):
        yield list(map(int, input().split()))

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

    books = np.array(list(readlines(N)))
    ans = np.inf
    for bit in product([0, 1], repeat=N):
        comb_sum = np.dot(np.array(bit), books)
        if all(comb_sum[1:] >= X):
            ans = min(ans, comb_sum[0])

    print(ans)
        


main()

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m,x = map(int,input().split())
t = [ i + 1 for i in range(0,n)]
res = []
for i in range(n):
    c_a = list(map(int,input().split()))
    res.append(c_a)
import itertools
choice = []
def all_choice(x,n):
    for i in x:
        for j in itertools.combinations(range(0,n), i):
            choice.append(j)
    return choice
all_choice = all_choice(t,n)
count = 10**5+1
for a in all_choice:
    res_0 = np.array([res[i] for i in a])
    flag = 0
    for i in range(m):
        if sum([t[i+1] for t in res_0]) < x:
            flag = 1
            break
    if flag == 0:
        new = sum([t[0] for t in res_0])
        if new<count:
            count = new
if count == 10**5+1:
    print(-1)
else:
    print(count)

Submission status: Wrong Answer

Solution code:
import itertools
n,m,x=map(int,input().split())
c=[0]*n
a=[[0 for i in range(m)] for j in range(n)]
print(a)
current_skill=[0]*m
INF=9999999
min_money=INF


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

current_money=0

for i in range(1 << n):
    bug=[]
    #print('current_money=',current_money)
    #print('current_skill=',current_skill)
    for j in range(n):
        if (i>>j) &1:
            bug.append(j)
    current_skill=[0]*m
    current_money=0
    for chosen_set_num in bug:
        current_money+=c[chosen_set_num]
        for each_book_num in range(m):
            current_skill[each_book_num]+=a[chosen_set_num][each_book_num]
            

        if all(status >=x for status in current_skill ):
            min_money=min(min_money,current_money)
            continue
if min_money==INF:
    min_money=-1
print(min_money)

Submission status: Wrong Answer

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

c = []
a = []
for nn in range(n):
    ca = input().split(" ")
    c.append(int(ca[0]))
    a.append([])
    for mm in range(m):
        a[nn].append(int(ca[mm + 1]))


# check if the criteria will have been accomplished
def satisfy_criteria():
    for mm in range(m):
        knowledge_level = 0
        for nn in range(n):
            knowledge_level += a[nn][mm]

        if knowledge_level < x:
            return False

    return True


def get_cost(pattern, c, n):
    cost = 0
    for i in range(n):
        if (pattern >> i) % 2 == 1:
            cost += c[i]
    return cost


def get_knowledge_level(pattern, a, m, x):
    for mm in range(m):
        knowledge_level = 0
        for i in range(n):
            if (pattern >> i) % 2 == 1:
                knowledge_level += a[i][mm]

        if knowledge_level < x:
            return False
    return True


satisfy = satisfy_criteria()

min_cost = (10 ** 5) + 1  # cause its max valut will be 10^5
if satisfy:
    # for all patterns
    for pattern in range(1, 2 ** n + 1):
        satisfy = get_knowledge_level(pattern, a, m, x)

        if satisfy:
            cost = get_cost(pattern, c, n)
            if min_cost > cost:
                min_cost = cost

    print(min_cost)
else:
    print("-1")

Submission status: Wrong Answer

Solution code:
import itertools

N, M, X = map(int, input().split())
List = [list(map(int, input().split())) for n in range(N)]
INF = 10**7
ans = INF
C_pro = list(itertools.product([0,1], repeat=N))

for c_pro in C_pro:
    count = 0
    cost = 0
    ans_list = [0 for i in range(M)]
    for c in c_pro:
        if c == 1:
            cost += List[count][0]
            ans_list = [answ+list for answ, list in zip(ans_list,List[count][1:])]
        count += 1
    if ans_list >= [X for i in range(M)]:
        ans = min(ans, cost)
    

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

Submission status: Wrong Answer

Solution code:
import itertools

N, M, X = map(int, input().split())
List = [list(map(int, input().split())) for n in range(N)]
INF = 10**7
ans = INF
C_pro = list(itertools.product([0,1], repeat=N))

for c_pro in C_pro:
    count = 0
    cost = 0
    ans_list = [0 for i in range(M)]
    for c in c_pro:
        if c == 1:
            cost += List[count][0]
            ans_list = [ans+list for ans, list in zip(ans_list,List[count][1:])]
        count += 1
    if ans_list >= [X for i in range(M)]:
        ans = min(ans, cost)
    

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

Submission status: Wrong Answer

Solution code:
import itertools

N, M, X = map(int, input().split())
List = [list(map(int, input().split())) for n in range(N)]
INF = 10**7
ans = INF
C_pro = list(itertools.product([0,1], repeat=N))

for c_pro in C_pro:
    count = 0
    cost = 0
    ans_list = [0 for i in range(M)]
    for c in c_pro:
        if c == 1:
            cost += List[count][0]
            ans_list = [ans+list for ans, list in zip(ans_list,List[count][1:])]
        count += 1
    if ans_list >= [X for i in range(M)]:
        ans = min(ans, cost)
    

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

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
l = []
dp = [[] for _ in range(n+1)]
for _ in range(n):
  a = list(map(int, input().split()))
  l.append(a)
dp[0].append([0 for _ in range(m+1)])
ans = []
for i in range(n):
  for row in dp[i]:
    dp[i+1].append(row)
    for j in range(m+1):
      row[j] += l[i][j]
    dp[i+1].append(row)
for row in dp[n]:
  cnt = 0
  for j in range(1, m+1):
    if row[j] >= x:
      cnt += 1
  if cnt == m:
    ans.append(row[0])
if len(ans) == 0:
  print(-1)
else:
  ans.sort()
  print(ans[0])

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
l = []
dp = [[] for _ in range(n+1)]
for _ in range(n):
  a = list(map(int, input().split()))
  l.append(a)
dp[0].append([0 for _ in range(m+1)])
ans = []
for i in range(n):
  for row in dp[i]:
    dp[i+1].append(row)
    cnt = 0
    for j in range(m+1):
      if j == 0:
        row[0] += l[i][0]
      else:
        row[j] += l[i][j]
        if row[j] >= x:
          cnt += 1
    if cnt == m:
      ans.append(row[0])
    dp[i+1].append(row)
if len(ans) == 0:
  print(-1)
else:
  ans.sort()
  print(ans[0])

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)]
ans = 0
cost = sum(c)
for i in range(2**n):
    kari = 0
    skill = [0] * m
    for j in range(n):
        if (i >> j) & 1:
            kari += c[j] 
            skill = [x + y for (x,y) in zip(skill,a[j])]
            
    if all([z >= x for z in skill ]):
        cost= min(cost,kari)
        ans += 1
        
if ans == 0:
    print("No")
else:
    print(cost)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
s = list(map(int, input().split()))
n = s[0]
m = s[1]
x = s[2]
book = []

for i in range(n):
    s = list(map(int, input().split()))
    book.append(s)
book=np.array(book)
ans=math.inf

for i in range(1<<n):

    skill = [0]*(m+1)
    for j in range(n):
        if i>>j & 1:
            for k,l in enumerate(book[j]):
                skill[k]+=l

    ok=1
    for j in range(1,m):
        if skill[j]<x :ok=0
    if ok:
        ans=min(ans,skill[0])
if ans==math.inf:
    ans=-1
print(ans)

Submission status: Wrong Answer

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

CA = [list(map(int, input().split())) for n in range(N)]

ans = 12*10**5

for i in range(2**N):
  cost = 0
  skills = [0] * M
  for j in range(N):
    if ((i >> j) & 1):
      #print(i, j)
      for k in range(M):
        skills[k] += CA[j][1+k]
      cost += CA[j][0]
  #print("skills", skills)
  if all([n >= X for n in skills]):
  	ans = min(ans, cost)
  #print("ans", ans)
if ans == 12*10**5:
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools
 
N, M, X = map(int, input().split())
C_list = []
ans = []
 
for _ in range(N):
    C_list.append(list(map(int, input().split())))
    
for i in range(1,N+1):
    for j in itertools.combinations(C_list, i):
        a = np.zeros(M+1)
        for k in j:
            a += np.array(k)
        if np.all(a[1:]>=X):
            ans.append(a[0])
if ans:
    print(int(min(ans)))

Submission status: Wrong Answer

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

N,M,X = map(int,readline().split())
books = [None] * N
for i in range(N):
  data = list(map(int,readline().split()))
  cost = data[0]
  point = data[1:]
  books[i] = [cost,point]
  
# M個から1個以上M個以下を選ぶ。選ぶ数でループ
INF = 10 ** 10
ans = INF
import itertools
for i in range(1, M + 1):
  for target in itertools.combinations(books, i):
    skills = [0] * M
    totalcost = 0
    for t in target:
      totalcost += t[0]
      point = t[1]
      for j in range(len(point)):
        skills[j] += point[j]
    if totalcost < ans:
      for j in range(len(skills)):
        if skills[j] < X:
          break
      else:
        ans = totalcost
if ans == INF:
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
c=[list(map(int,input().split())) for _ in range(n)]
result=-1
for i in range(2**n):
  t=[0]*m
  money=0
  for j in range(n):
    if (i>>j)&1==0:
      continue
    money+=c[j][0]
    for k in range(1,m):
      t[k]+=c[j][k]
  if all(xx>=x for xx in t):
    if result==-1:
      result=money
    else:
      result=min(result,money)
print(result)

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
c=[list(map(int,input().split())) for _ in range(n)]
result=-1
for i in range(2**n):
  t=[0]*m
  money=0
  for j in range(n):
    if (i>>j)&1==0:
      continue
    money+=c[j][0]
    for k in range(m):
      t[k]+=c[j][k]
  if all(xx>=x for xx in t):
    if result==-1:
      result=money
    else:
      result=min(result,money)
print(result)

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
a=[list(map(int,input().split()))for i in range(n)]
ans=[]
for bit in range(1>>n):
  total=0
  skill=[0]*m
  for i in range(n):
    if bit & (1>>i):
      total+=a[i][0]
      for j in range(m):
        skill[j]+=a[i][j]
  if all([k>=x for k in skill]):
    ans.append(total)
print(min(ans) if len(ans)!=0 else -1)

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
a=[list(map(int,input().split()))for i in range(n)]
ans=[]
for bit in range(1>>n):
  total=0
  skill=[0]*m
  for i in range(n):
    if bit & (1>>i):
      total+=a[i][0]
      for j in range(m):
        skill[j]+=a[i][j]
  if all([k>x for k in skill]):
    ans.append(total)
print(min(total) if len(ans)>=1 else -1)