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:
import numpy as np

data = input().split()
n = int(data[0])
m = int(data[1])
x = int(data[2])
data = []
for _ in range(n):
    data.append(np.array(list(map(int,input().split()))))

ans = 10000000
for b in range(2**n):
    value = np.array([0 for _ in range(m+1)])
    b = bin(b)[2:]
    for zero in range(n-len(b)):
        b = "0" + b
    for i in range(n):
        if b[i] == 1:
            value += data[i]
    ok = True
    for i in range(1,m+1):
        if value[i] < x:
            ok = False
    if ok == True and value[0] <= ans:
        ans = value[0]

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N, M, X = list(map(int, input().split()))
li = defaultdict(list)

for i in range(N):
    ca = list(map(int, input().split()))
    li[ca[0]] = ca[1:]
li = sorted(li.items())

su = 0
A = [0]*M
for i in range(len(li)):
    su += int(li[i][0])
    for j in range(M):
        A[j] += int(li[i][1][j])
#print(A)
if any(A[j]<X for j in range(len(A))):
    print('-1')
    exit()
#print(len(li))
#print(su)
answer = su
for j in range(len(li)-1, -1, -1):
    ans = su
    temp = []
    tem = []
    for i in range(j, -1, -1):
        temp = li[i][1]
        tem = [x-y for (x, y) in zip(A, temp)]
        if all(tem[j]>=X for j in range(len(A))):
            #print('minus:', li[i][0])
            ans -= li[i][0]
            A = tem
            continue
        else:
            continue
    answer = min(ans, answer)

print(answer)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N, M, X = list(map(int, input().split()))
li = defaultdict(list)

for i in range(N):
    ca = list(map(int, input().split()))
    li[ca[0]] = ca[1:]
li = sorted(li.items())

su = 0
A = [0]*M
for i in range(len(li)):
    su += int(li[i][0])
    for j in range(M):
        A[j] += int(li[i][1][j])
#print(A)
if any(A[j]<X for j in range(len(A))):
    print('-1')
    exit()
#print(len(li))
#print(su)
for j in range(len(li)-1, -1, -1):
    ans = su
    answer = su
    temp = []
    tem = []
    for i in range(j, -1, -1):
        temp = li[i][1]
        tem = [x-y for (x, y) in zip(A, temp)]
        if all(tem[j]>=X for j in range(len(A))):
            #print('minus:', li[i][0])
            ans -= li[i][0]
            A = tem
            continue
        else:
            continue
    answer = min(ans, answer)

print(answer)

Submission status: Wrong Answer

Solution code:
N,M,X = map(int ,input().split())
book_list = []
cost=[0]*(2**N)
rikaido = [0]*M
cost_paform = []
for i in range(N):
    book_list.append(list(map(int ,input().split())))
for i in range(2 ** N):
    bag = []
    rikaido = [0] * M
    for j in range(N):  # このループが一番のポイント
        if (i >> j& 1):
            bag.append(j)
    for k in range(len(bag)):
        #print(bag)
        #print(bag[k])
        cost[i] = cost[i] + book_list[bag[k]][0]
        for m in range(M):
            rikaido[m] = rikaido[m] + book_list[bag[k]][m]

    flag = 0
    for m in range(M):
        if rikaido[m]<X: flag = 1
    if flag == 0:
        cost_paform.append(cost[i])

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N, M, X = list(map(int, input().split()))
li = defaultdict(list)

for i in range(N):
    ca = list(map(int, input().split()))
    li[ca[0]] = ca[1:]
li = sorted(li.items())

su = 0
A = [0]*M
for i in range(len(li)):
    su += int(li[i][0])
    for j in range(M):
        A[j] += int(li[i][1][j])
#print(A)
if any(A[j]<X for j in range(len(A))):
    print('-1')
    exit()
#print(len(li))
#print(su)
ans = su
answer = su
temp = []
tem = []
for j in range(len(li)-1, -1, -1):
    for i in range(j, -1, -1):
        temp = li[i][1]
        tem = [x-y for (x, y) in zip(A, temp)]
        if all(tem[j]>=X for j in range(len(A))):
            #print('minus:', li[i][0])
            ans -= li[i][0]
            A = tem
            continue
        else:
            continue
    answer = min(ans, answer)

print(answer)

Submission status: Wrong Answer

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

ans = 10**10
for i in range(1<<n):
    score = 0
    li = [0]*m
    for j in range(n):
        LL = L[j][1:]
        
        if (i>>j)&1:
            score += L[j][0]
            for k in range(m):
                li[k] +=LL[k]
    if all(x >= p for x in li):
        ans = min(ans,score)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N, M, X = map(int, input().split())
C = []
A = [[] for i in range(M)]
resC = []
resA = list(A)

NEW = 0

def update(base):
  #print(NEW,base)
  if base==None:
    return NEW
  return base + NEW

def check(num):
  return num>=X

def check2(*args):
  res = True
  for val in args:
    buf = (val >= X)
    res = res and buf
  return res

for i in range(N):
  buf = list(map(int, input().split()))
  C.append(buf[0])
  for j in range(M):
    A[j].append(buf[j+1])

for i in range(N):
  if i == 0:
    NEW = C[i]
    resC = [0, NEW]
    resA = [[0, A[j][i]] for j in range(M)]
  else:
    NEW = C[i]
    resC = resC + list(map(update, resC))
    for j in range(M):
      NEW = A[j][i]
      resA[j] = resA[j] + list(map(update, resA[j]))

res = list(map(check2, *resA))
print(np.asarray(resC)[res]) 
if sum(res)==0:
  print(-1)
else:
  print(min(np.asarray(resC)[res]))

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np

def calc(aaa, M, X, pattern):
    tmp_price = 0
    for t in pattern:
        price = 0
        sum = np.zeros(M)
        for i in t:
            price += aaa[i][0]
            current = np.array(aaa[i][1:M+1])
            sum = sum + current

        if np.count_nonzero(sum >= X) >= M:
            if tmp_price == 0:
                tmp_price = price
            else:
                tmp_price = min(tmp_price, price)

    return tmp_price


def solve(N, M, X, aaa):

    for i in range(N):
        pattern = list(itertools.combinations(range(N), i + 1))
        result = calc(aaa, M, X, pattern)
        if result > 0:
            return result

    return -1

N, M, X, *A = map(int, open(0).read().split())

aaa = []
aa = []
for index, x in enumerate(A):
    aa.append(x)
    if (index+1) % (M+1) == 0:
        aaa.append(aa)
        aa = []

print(solve(N, M, X, aaa))

Submission status: Wrong Answer

Solution code:

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

ans = -1
for i in range(2**n):
    li = [0]*(m+1)
    print('＝＝＝＝＝＝＝＝＝＝')
    for j in range(n):
        print('i = ', i)
        print('j = ', j)
        print('(i >> j) = ', (i >> j))
        print('((i >> j) & 1) = ', ((i >> j) & 1))
        if ((i >> j) & 1):
            for k in range(m+1):
                li[k] += ca[j][k]
        print('li = ', li)
    for j in range(1, m+1):
        if li[j] < x:
            break
    else:
        if ans == -1:
            ans = li[0]
        else:
            if ans > li[0]:
                ans = li[0]
print(ans)

Submission status: Wrong Answer

Solution code:
def ip():return list(map(int,input().split()))

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

ans=12*10**5
for i in range(1,2**n):
    f=bin(i)[2:]
    sum=[0]*m
    while len(f)<n:f='0'+f
    s=0
    for j in range(n):
        if f[j]=='1':
            s+=c[j]
            for h in range(m):
                sum[h]+=a[j][h]
    F=True
    for h in range(m):
        if sum[h]<x:F=False
    if F==True:ans=min(ans,s)
print(ans) if ans!=12*10**5 else print(-1)

Submission status: Wrong Answer

Solution code:
# C - Skill Up

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

books = []
append = books.append
max_exp = [0] * M
for i in range(N):

    CA = list(map(int, input().split()))

    append(
        {
            'price': CA[0],
            'get_exp': CA[1:],
            'koritsu': sum(CA[1:]) / CA[0]
        }
    )
    for ind, j in enumerate(max_exp):
        max_exp[ind] += CA[ind + 1]

books = sorted(
    books,
    key=lambda x: x['price']
)
books = sorted(
    books,
    key=lambda x: x['koritsu'],
    reverse=True
)

# check
if min(max_exp) < X:
    print(-1)
else:
    exps = [0] * M
    price = 0

    while min(exps) < X:

        price += books[0]['price']

        for ind, exp in enumerate(books[0]['get_exp']):
            exps[ind] += exp

        del books[0]
        min_idx = exps.index(min(exps))
        books = sorted(
            books,
            key=lambda x: x['price']
        )
        books = sorted(
            books,
            key=lambda x: abs(x['get_exp'][min_idx] - (X - exps[min_idx]))
        )

    print(price)

Submission status: Wrong Answer

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

books = []
append = books.append
max_exp = [0] * M
for i in range(N):

    CA = list(map(int, input().split()))

    append(
        {
            'price': CA[0],
            'get_exp': CA[1:],
            'koritsu': sum(CA[1:]) / CA[0]
        }
    )
    for ind, j in enumerate(max_exp):
        max_exp[ind] += CA[ind + 1]

books = sorted(
    books,
    key=lambda x: x['price']
)
books = sorted(
    books,
    key=lambda x: x['koritsu'],
    reverse=True
)

# check
if min(max_exp) < X:
    print(-1)
else:
    exps = [0] * M
    price = 0

    while min(exps) < X:

        price += books[0]['price']

        for ind, exp in enumerate(books[0]['get_exp']):
            exps[ind] += exp

        del books[0]
        min_idx = exps.index(min(exps))
        books = sorted(
            books,
            key=lambda x: x['price']
        )
        books = sorted(
            books,
            key=lambda x: x['get_exp'][min_idx] / x['price'],
            reverse=True
        )

    print(price)

Submission status: Wrong Answer

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

books = []
append = books.append
max_exp = [0] * M
for i in range(N):

    CA = list(map(int, input().split()))

    append(
        {
            'price': CA[0],
            'get_exp': CA[1:],
            'koritsu': sum(CA[1:]) / CA[0]
        }
    )
    for ind, j in enumerate(max_exp):
        max_exp[ind] += CA[ind + 1]

books = sorted(
    books,
    key=lambda x: x['koritsu'],
    reverse=True
)

# check
if min(max_exp) < X:
    print(-1)
else:
    exps = [0] * M
    price = 0

    while min(exps) < X:

        price += books[0]['price']

        for ind, exp in enumerate(books[0]['get_exp']):
            exps[ind] += exp

        del books[0]
        min_idx = exps.index(min(exps))
        books = sorted(
            books,
            key=lambda x: x['get_exp'][min_idx] / x['price'],
            reverse=True
        )
        books = sorted(
            books,
            key=lambda x: x['price']
        )

    print(price)

Submission status: Wrong Answer

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

books = []
append = books.append
max_exp = [0] * M
for i in range(N):

    CA = list(map(int, input().split()))

    append(
        {
            'price': CA[0],
            'get_exp': CA[1:],
            'koritsu': sum(CA[1:]) / CA[0]
        }
    )
    for ind, j in enumerate(max_exp):
        max_exp[ind] += CA[ind + 1]

books = sorted(
    books,
    key=lambda x: x['koritsu'],
    reverse=True
)

# check
if min(max_exp) < X:
    print(-1)
else:
    exps = [0] * M
    price = 0

    while min(exps) < X:

        price += books[0]['price']

        for ind, exp in enumerate(books[0]['get_exp']):
            exps[ind] += exp

        del books[0]
        min_idx = exps.index(min(exps))
        books = sorted(
            books,
            key=lambda x: x['get_exp'][min_idx] / x['price'],
            reverse=True
        )

    print(price)

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)]
l = 0
for i in range(2 ** n):
    ans = sum(c)
    get = [0] * m
    kari = 0
    for j in range(n):
        if (i >> j) & 1: #i(ex.5)を2進数(ex.101)に一桁ずつ変換
            get = [x + y for (x, y) in zip(get, a[j])]
            kari += c[j]
    if all([z >= x for z in get]):
        ans = min(ans,kari)
        l += 1
if l == 0:
    ans = -1

print(ans)

Submission status: Wrong Answer

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

books = []
append = books.append
max_exp = [0] * M
for i in range(N):

    CA = list(map(int, input().split()))

    append(
        {
            'price': CA[0],
            'get_exp': CA[1:],
            'koritsu': sum(CA[1:]) / CA[0]
        }
    )
    for ind, j in enumerate(max_exp):
        max_exp[ind] += CA[ind + 1]

books = sorted(
    books,
    key=lambda x: x['koritsu'],
    reverse=True
)

# check
if min(max_exp) < X:
    print(-1)
else:
    exps = [0] * M
    price = 0

    for b in books:
        if min(exps) >= X:
            break

        price += b['price']

        for ind, exp in enumerate(b['get_exp']):
            exps[ind] += exp

    print(price)

Submission status: Wrong Answer

Solution code:
#ABC167-C
import itertools
flg = True
n,m,x = map(int,input().split())
algo = []
tmp = []
for _ in range(n):
    algo.append(list(map(int,input().split())))
    
book = list(itertools.product([0,1],repeat=n))
abi = [0 for _ in range(m)]

for pattern in book:
    #値の初期化
    abi = [0 for _ in range(m)]
    money = 0
    flg = True
    
    for i in range(len(pattern)):
        for j in range(m):
            abi[j] += algo[i][j+1] * pattern[i]
        money += algo[i][0] * pattern[i]
        
    abi_min = [p for p in abi if p < x]
        
    if len(abi_min) != 0:
        flg = False
    if flg:
        print(money)
        tmp.append(money)

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

Submission status: Wrong Answer

Solution code:
from functools import reduce

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

mincost = 10**8

for i in range(2**n):
	case = [0] * (m+1)
	for j in range(m+1):
		if (i >> j) & 1:
			case = list(map(sum, zip(case, lb[j])))
	
	if reduce(lambda u, v: u and v, list(map(lambda y: y >= x, case[1:]))):
		mincost = min(mincost, case[0])

if mincost < 10**8:
	print(mincost)
else:
	print(-1)

Submission status: Wrong Answer

Solution code:
n, m, k = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]
a = []
n2 = 2 ** n
for i in range(n2):
  b = 0
  c = 0
  i22 = bin(i)
  i2 = i22.lstrip("0b")
  i2liststr = list(i2)
  i2list = [0] * (n - len(i2liststr)) + [int(j) for j in i2liststr]
  for o in range(m):  
    for j in range(len(i2list)):
      b += i2list[j] * l[j][o+1]
    if b >= k:
      c += 1
  if c == m:
    aappend  = 0
    for p in range(n):
      aappend += i2list[p] * l[p][0]
    a.append(aappend)
if a == []:
  print(-1)
else:
  print(min(a))

Submission status: Wrong Answer

Solution code:
#Solver:Rute
n,m,x = map(int,input().split())
money = []
#データ入力
ls = []
for i in range(n):
  ls.append(list(map(int,input().split())))
#bit全探索
for i in range(2**n):
  now = format(i,'b')
  cost = 0
  #理解度のリスト
  understand = [0]*m
  for j in range(len(now)):
    if now[j] == "1":
      cost += ls[-(j+1)][0]
      for k in range(m):
        understand[k] += ls[-(j+1)][k+1]
  if min(understand) >= x:
    money.append(cost)
if len(money) == 0:
  print(-1)
else:
  print(min(money))

Submission status: Wrong Answer

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

price=0
ans=100000

for i in range(1, 2**N):
  price=0
  rikaido = [0]*M
  for j in range(N):
    if i>>j & 1:
      price += int(CAAA[j][0])
      for k in range(M):
        rikaido[k] += int(CAAA[j][k+1])
        for l in rikaido:
          if l < X:
            break
          else:
            ans = min(ans, price)
if ans == 100000:
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
# ABC167 C

def main():
    n, m, x = map(int, input().split())
    List = []
    
    for _ in range(n):
        tmp = list(map(int, input().split()))
        List.append(tmp)

    minCost = 10**9

    for i in range(1, 2**n):
        inBit = bin(i)[2:][::-1]
        knowledge = [0 for _ in range(m)]
        cost = 0

        for bit in range(len(inBit)):
            if inBit[bit] == '1':
                cost += List[bit][0]
                for j in range(m):
                    knowledge[j] += List[bit][j+1]
        
        if knowledge >= [x for _ in range(m)] and cost < minCost:
            minCost = cost
    
    if minCost == 10**9:
        print(-1)
    else:
        print(minCost)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from itertools import product

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

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

result = float('inf')
for p in product([True, False], repeat = N):
    t = [0] * M
    c = 0
    for j in range(N):
        if not p[j]:
            continue
        c += C[j]
        for k in range(M):
            t[k] += A[j][k]
    if all(x >= X for x in t):
        result = min(result, c)
print(result)

Submission status: Wrong Answer

Solution code:

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

import numpy as np

all = np.zeros(n*(m+1)).reshape(n,m+1)

for i in range(n):
    all[i] += [int(e) for e in input().split()]

bool_list = np.array([])
a = []
b = []
def make(n):
    if len(a) == n:
        b.append([0 for _ in range(n)])
        for i,v in enumerate(a) :
            if v == True:
                b[-1][i] = True
            else:
                b[-1][i] = False
    else:
        for i in [True,False]:
            a.append(i)
            make(n)
            a.pop()

make(n)
c=np.array(b)

dp=10**10

for i in c:
    if all[i][:,1].sum(axis = 0) >=x :
        dp = min(dp,all[i][:,0].sum(axis = 0))

if dp ==10**10:
    dp = -1
print(int(dp))

Submission status: Wrong Answer

Solution code:
import numpy as np

_,*_t=[list(map(int,i.split())) for i in open(0)]
n=_[0]
m=_[1]
x=_[2]
table=np.array(_t)
value=9000000


def boolAchieve(nums):
  for i in range(1,m+1):
    if nums[i]<x:
      return False
  return True


tmp=np.sum(table,axis=0)
if not boolAchieve(tmp):
  print(-1)
  exit()


for i in range(1,2 ** n):
  selects=[bool(i >> j) for j in range(n)]
  picks=np.sum(table[selects,:],axis=0)
  if not boolAchieve(picks):
    continue
  value=min(value,picks[0])

  
print(value)

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 =1000000000000000000
for bi in range(int("1"*n,2)):
    l = [0]*m
    p = 0
    for k,si in enumerate(str(format(bi,f"0{n}b"))):
        if si=="1":
            b = a[k]
            for j,i in enumerate(b[1:]):
                l[j]+=i
            p+=b[0]
    if all([i>=x for i in l]):
        ans=min(ans,p)
if ans==1000000000000000000:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
# AtCoder Beginner Contest 167
N,M,X=map(int,input().split(" "))
array=[]
ans = 1001001001
for i in range(N):
     H = input().rstrip()
     array.append(H.split(" "))
# print(array)

for i in range(1<<N): #2の3条になる(1をNビット右にシフトするから)
    cost = 0
    understand = [0 for un in range(M)]
    # print(understand)
    for j in range(N):
        if(((i>>j)&1)): #a&b : AND:論理積 100*010 = 000, 100+100=100,シフトしたあと１との論理積を取ることで必要なビット田だけ取り出せる
            ar = array[j][0]
            cost+=int(ar)
            for un in range(M):
                a1 = array[j][un+1]
                understand[un]+=int(a1)
        ok = True
    for un in range(M):
        if understand[un]<X:
            ok = False
    if ok:
        ans = min(ans, cost)
        # print(understand)
        # print(cost)
print(ans)

Submission status: Wrong Answer

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

final = 1000000000

for i in range(1, N ** 2):
    ans = 0
    rikai = [0]*M
    for j in range(N):
        if ((i >> j) & 1):
            for k in range(1, M+1):
                rikai[k-1] += A[j][k]
            ans += A[j][0]
    if all(el >= X for el in rikai):
        final = min(final, ans)

if final == 1000000000:
    print(-1)
else:
    print(final)

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split(" "))
book_information = []
result = 12 * 10**5
for i in range(N):
	book_information.append(input())
for i in range(1, 1 << N):
  bought_book = []
  n = 0
  cost = 0
  skill = [0 for j in range(M)]
  for j in range(N):
    if (i >> j) & 1:
      bought_book.append(book_information[j])
      n += 1
  for j in range(n):
    bought_book_information = list(bought_book[j].split(" "))
    cost += int(bought_book_information[0])
    for k in range(M):
      skill[k] += int(bought_book_information[k + 1])
  if all(x >= X for x in skill):
    result = min(result, cost)
if result == 12 * 10**5:
  print(-1)
else:
  print(result)

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split(" "))
book_information = []
result = 12 * 10**5
for i in range(N):
	book_information.append(input())
for i in range(1, 1 << N):
  bought_book = []
  n = 0
  cost = 0
  skill = [0 for j in range(M)]
  for j in range(N):
    if (i >> j) & 1:
      bought_book.append(book_information[j])
      n += 1
  for j in range(n):
    bought_book_information = list(bought_book[j].split(" "))
    cost += int(bought_book_information[0])
    for k in range(M):
      skill[k] += int(bought_book_information[k + 1])
  if all(x >= X for x in skill):
    result = min(result, cost)
if result == 12 * 10**5:
  print(-1)
else:
  print(result)

Submission status: Wrong Answer

Solution code:
import itertools
n,m,x=map(int,input().split())
lis=tuple(tuple(map(int,input().split())) for _ in range(n))
ans=float("inf")

def dfs(progress,skills,nowcost):
    global ans
    if progress==n:
        if all(v>=x for v in skills):
            ans=min(ans,nowcost)
        return ans
    dfs(progress+1,skills,nowcost)
    dfs(progress+1,[a+b for a,b in zip(skills,lis[progress][1:])],nowcost+lis[progress][0])

if dfs(0,[0]*m,0)==float("inf"):
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

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

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

result = float('inf')
for i in range(1 << N):
    t = [0] * M
    c = 0
    for j in range(N):
        if (i >> j) & 1 == 0:
            continue
        c += C[j]
        a = A[j]
        for k in range(M):
            t[k] += a[k]
    if all(x >= X for x in t):
        result = min(result, c)
print(result)

Submission status: Wrong Answer

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

matrix = []
c = []
ans = 100001

for i in range(N):
    matrix.append(list(map(int, input().split())))
    c.append(matrix[i].pop(0))

for i in range(2 ** N):
    cost = 0
    rikai = [0] * M
    for j in range(N):
        if ((i >> j) & 1):
            cost += c[j]
            for k in range(M):
                rikai[k] += matrix[j][k]
    flg = True
    for k in range(M):
        if rikai[k] < X:
            flg = False
    if flg:
        ans = min(ans, cost)
    

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

Submission status: Wrong Answer

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

matrix = []
c = [0] * N
ans = 100000

for i in range(N):
    matrix.append(list(map(int, input().split())))
    c[i] = matrix[i].pop(0)


for i in range(2 ** N):
    cost = 0
    rikai = [0] * M
    for j in range(N):
        if ((i >> j) & 1):
            cost += c[j]
            for k in range(M):
                rikai[k] += matrix[j][k]
    flg = True
    for k in range(M):
        if rikai[k] < X:
            flg = False
    if flg:
        ans = min(ans, cost)
    

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

Submission status: Wrong Answer

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

matrix = []
c = []
ans = 100000

for i in range(N):
    matrix.append(list(map(int, input().split())))
    c.append(matrix[i].pop(0))

for i in range(2 ** N):
    cost = 0
    rikai = [0] * M
    for j in range(N):
        if ((i >> j) & 1):
            cost += c[j]
            for k in range(M):
                rikai[k] += matrix[j][k]
    flg = True
    for k in range(M):
        if rikai[k] < X:
            flg = False
    if flg:
        ans = min(ans, cost)
    

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

Submission status: Wrong Answer

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

matrix = []
c = []
ans = 100000

for i in range(N):
    matrix.append(list(map(int, input().split())))
    c.append(matrix[i].pop(0))

for i in range(2 ** N):
    cost = 0
    rikai = [0] * M
    for j in range(N):
        if ((i >> j) & 1):
            cost += c[j]
            for k in range(M):
                rikai[k] += matrix[j][k]
    flg = True
    for k in range(M):
        if rikai[k] < X:
            flg = False
    if flg:
        ans = min(ans, cost)

if ans == 100000:
    print(-1)
else:
    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')
def dfs(step, m_list, cost):
    global ans
    if all(elem>=x for elem in m_list):
        ans = min(cost, ans)
    elif step != n:
        dfs(step+1, m_list, cost)
        m_list = [x+y for x, y in zip(m_list, a[step][1:])]
        cost += a[step][0]
        dfs(step+1, m_list, cost)

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

Submission status: Wrong Answer

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

matrix = []
c = []
ans = 100000

for i in range(N):
    matrix.append(list(map(int, input().split())))
    c.append(matrix[i].pop(0))

for i in range(2 ** N):
    cost = 0
    rikai = [0] * M
    for j in range(N):
        if ((i >> j) & 1):
            cost += c[j]
            for k in range(M):
                rikai[k] += matrix[j][k]
    flg = True
    for k in range(M):
        if rikai[k] < X:
            flg = False
    if flg:
        ans = min(ans, cost)

if ans != 100000:
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import itertools
n,m,x=map(int,input().split())
lis=tuple(tuple(map(int,input().split())) for _ in range(n)) #再代入しないので二次元tupleでよい
ans=float("inf")

for choice in itertools.product(range(2),repeat=n):#0,1のbit全探索
    cost=0
    skills=[0]*m
    for flag,book in zip(choice,lis):
        if flag:
            C,A = book[0],book[1:]
            cost += book[0]
            for i,a in enumerate(A):
                skills[i]+=a
    if all(v>=x for v in skills):
        ans=min(ans,cost)
print(ans)

Submission status: Wrong Answer

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

matrix = []
c = []
min = 100000
flg = True

for i in range(N):
    matrix.append(list(map(int, input().split())))
    c.append(matrix[i].pop(0))

for i in range(2 ** N):
    cost = 0
    rikai = [0] * M
    for j in range(N):
        if ((i >> j) & 1):
            cost += c[j]
            for k in range(M):
                rikai[k] += matrix[j][k]
    for k in range(M):
        if rikai[k] >= X:
            flg = True
        else:
            flg = False
            break
    if flg and cost < min:
        min = cost

if min != 100000:
    print(min)
else:
    print(-1)

Submission status: Wrong Answer

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

matrix = []
c = []
min = 100000
flg = True

for i in range(N):
    matrix.append(list(map(int, input().split())))
    c.append(matrix[i].pop(0))

for i in range(2 ** N):
    cost = 0
    rikai = [0] * M
    for j in range(N):
        if ((i >> j) & 1):
            cost += c[j]
            for k in range(M):
                rikai[k] += matrix[j][k]
    for k in range(M):
        if rikai[k] >= X:
            flg = True
        else:
            flg = False
            break
    if flg and cost < min:
        min = cost

if min != 100000:
    print(min)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
cam = [list(map(int, input().split())) for i in range(n)]
ans=10000*12

for i in range(2**n):
    a=[0]*m
    cst=0
    for j in range(n):
        bag=[]
        if (i>>j)&1:
            cst+=cam[j][0]
            for k in range(1,m+1):
                a[k-1]+=cam[j][k]
    if all(elem >= x for elem in a):
        ans=min(ans,cst)
    
if ans<100000*12:
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
bi_list = [bin(i) for i in range(2**n)] 
comb = [0] * (m+1)
comb[0] = 10**6
for i in bi_list:#本の選択パターン選択
    dig = len(i)
    state = [0] * (m+1)
    for j in range(dig):#iから本の選択
        if i[dig-1-j] == '1':
            for k in range(m+1):#本の数値入力
                state[k] += l[n-1-j][k]
                
    for p in range(m):
        if state[m - p] < x:
            break
    else:
        if state[0] < comb[0]:
            comb = state
if comb[m] ==0:
    print(-1)
else:
    print(comb[0])