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:
nmx=list(map(int, input().split()))
N=nmx[0]
M=nmx[1]
X=nmx[2]
mylist=[]
for i in range(N):
    mylist.append(list(map(int, input().split())))
Ans=100000*12+1
for i in range(2**N):
    A=[0]*M
    C=0
    for j in range(N):
        if (i>>j) & 1:
            C=C+mylist[j][0]
            for k in range(M):
                A[k]=A[k]+mylist[j][k+1]
    if min(A)>=X:
        Ans=min(Ans, C)
if Ans==10000*12+1:
    print(-1)
else:
    print(Ans)

Submission status: Wrong Answer

Solution code:
nmx=list(map(int, input().split()))
N=nmx[0]
M=nmx[1]
X=nmx[2]
mylist=[]
for i in range(N):
    mylist.append(list(map(int, input().split())))
Ans=10000*12+1
for i in range(2**N):
    A=[0]*M
    C=0
    for j in range(N):
        if (i>>j) & 1:
            C+=mylist[j][0]
            for k in range(M):
                A[k]=A[k]+mylist[j][k+1]
    if min(A)>=X:
        Ans=min(Ans, C)
if Ans==10000*12+1:
    print(-1)
else:
    print(Ans)

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

satisfy = satisfy_criteria()

min_cost = (10 ** 5) + 1  # cause its max valut will be 10^5
if satisfy:
    # for all patterns
    for pattern_id in range(2 ** n):
        s = ""

        # for all text books
        cost = 0
        for i in range(n):
            if (pattern_id >> i) % 2 == 1:
                cost += c[i]
        satisfy = True
        # for all alg
        for mm in range(m):
            knowledge_level = 0
            for i in range(n):
                if (pattern_id >> i) % 2 == 1:
                    knowledge_level += a[i][mm]

            if knowledge_level < x:
                satisfy = False
                break

        if satisfy and (min_cost > cost):
            min_cost = cost
    print(min_cost)
else:
    print("-1")

Submission status: Wrong Answer

Solution code:
def function():
    N,M,X = map(int, input().split())
    maxCost=0
    Aij = []
    for n in range(0,N):
        Aj = list(map(int, input().split()))
        maxCost += Aj[0]
        Aij.append(Aj)

    minCost = maxCost
    total = pow(2, N)
    for n in range(1,total):
        x = [0]*M
        cost = 0
        i = 0
        while n>>i != 0:
            if (n>>i) & 1 == 1:
                Aj = Aij[i]
                cost += Aj[0]
                for j in range(1,len(Aj)):
                    x[j-1] += Aj[j]
            i += 1
        
        # check his understanding is higher than X
        higher = True
        for xv in x:
            if xv < X:
                higher = False
                break
        if higher == True:
            minCost = min(cost, minCost)
    if minCost == maxCost:
        minCost = -1
    print(minCost)

if __name__ == '__main__':
    function()

Submission status: Wrong Answer

Solution code:
from itertools import product
import numpy as np

N, M, X = list(map(int, input().split()))
books = np.array([list(map(int, input().split())) for i in range(N)])
ans = 10**5 * 12
for selection in product([0, 1], repeat=N):
    selection = np.array(selection).reshape(N, 1)
    res = (books * selection).sum(axis=0)
    if min(res[1:]) >= X:
        ans = min(ans, res[0])
print(ans if ans != 10**5 * 12 else -1)

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
cc = []
aa = []
for _ in range(n):
    c,*a = [int(i) for i in input().split()]
    cc.append(c)
    aa.append(a)
ans = 10**18
for i in range(2**n):
    ri = [0]*m
    co = 0
    for j in range(n):
        if ((i>>j) & 1):#c円するやつを，最下位bitが1なら購入
            co += cc[j] #購入したcの値段を加算
            for k in range(m):
                ri[k] += aa[j][k]#購入した箇所のパラメータを追加していく
               
    for j in ri:
        if j < x:
            break
        else:
            ans = min(ans,co)
        
if ans == 10**18:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
nmx=list(map(int, input().split()))
N=nmx[0]
M=nmx[1]
X=nmx[2]
list=[input().split() for i in range(N)]
flg=False
alist=[[0]*M]*2**N #全部の場合、2^N通りの成熟度をここに入れたい
clist=[0]*2**N #全部の場合の金額
for k in range(2**N):
    for i in range(N):
        if (k>>i) & 1:
            c=int(list[i][0])
            clist[k]+=c
            for j in range(M):
                a=int(list[i][j+1])
                alist[k][j]+=a
    if min(alist[k])<X:
        clist[k]=12*10**5
    else:
        flg=True
if flg:
    clist.sort()
    print(clist[0])
else:
    print('-1')

Submission status: Wrong Answer

Solution code:
import numpy as np
# dfsで全探索
n, m, x = map(int, input().split())
a = np.zeros((n, m+1))
for i in range(n):
    ll = list(map(int, input().split()))
    a[i] += np.array(ll)
    

ans = float("INF")
# 0: Not Buy 1: Buy
s = []

def dfs(s):
    global ans
    if len(s) == n:
        r = np.zeros(m+1)
        for j, k in enumerate(s):
            if k == 0:
                continue
            r += np.array(a[j])
        if min(r) >= x:
            ans = min(ans, int(r[0]))
        return
    b = s.copy()
    nb = s.copy()
    b.append(0)
    nb.append(1)
    dfs(b)
    dfs(nb)

dfs([])
if ans == float("INF"):
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
# dfsで全探索
n, m, x = map(int, input().split())
c = []
a = np.zeros((n, m))
for i in range(n):
    ll = list(map(int, input().split()))
    c.append(ll[0])
    a[i] += np.array(ll[1:])
    

ans = float("INF")
# 0: Not Buy 1: Buy
s = []

def dfs(s):
    global ans
    if len(s) == n:
        r = np.zeros(m)
        ra = 0
        for j, k in enumerate(s):
            if k == 0:
                continue
            r += np.array(a[j])
            ra += c[j]
        if min(r) >= x:
            ans = min(ans, ra)
        return
    b = s.copy()
    nb = s.copy()
    b.append(0)
    nb.append(1)
    dfs(b)
    dfs(nb)

dfs([])
if ans == 10**5 + 1:
    print(-1)
else:
    print(ans)

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)[2:] 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])

Submission status: Wrong Answer

Solution code:
from itertools import product
def main():
    n, m, x = map(int, input().split())
    books = []
    for _ in range(n):
        books.append(tuple(map(int, input().split())))

    books_set_all = []
    books_pattern = product((0, 1), repeat=n)
    for each_pattern in books_pattern:
        print(each_pattern)
        books_set = [0] * (m + 1)
        for i1 in range(n):
            if each_pattern[i1] == 1:
                for i2 in range(m + 1):
                    books_set[i2] += books[i1][i2]
        books_set_all.append(books_set)
    price_all = []
    for ebs in books_set_all:
        price = ebs[0]
        ebs[0] = x
        if len([j for j in ebs if j >= x]) == m + 1:
            price_all.append(price)
    if len(price_all) > 0:
        print(min(price_all))
    else:
        print(-1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
C = [0] * N
A = [[0 for _ in range(M)] for _ in range(N)]
for i in range(N):
  A[i] = list(map(int, input().split()))
  C[i] = A[i][0]
  A[i] = A[i][1:]
ans = sum(C) + 1
Y = [0] * M
for p in range(2 ** N):
  for i in range(M):
    Y[i] = 0
  cnt = 0
  _p = p
  for i, c in enumerate(C):
    if _p % 2 == 1:
      cnt += c
      for j, a in enumerate(A[i]):
        Y[j] += a
    _p //= 2
  ans = min(ans, cnt) if min(Y) >= X else ans
print(ans if ans < sum(C) else -1)

Submission status: Wrong Answer

Solution code:
import numpy as np
# dfsで全探索
n, m, x = map(int, input().split())
c = []
a = np.zeros((n, m))
for i in range(n):
    ll = list(map(int, input().split()))
    c.append(ll[0])
    a[i] += np.array(ll[1:])
    

ans = 10**5  + 1
# 0: Not Buy 1: Buy
s = []

def dfs(s):
    global ans
    if len(s) == n:
        r = np.zeros(m)
        ra = 0
        for j, k in enumerate(s):
            if k == 0:
                continue
            r += np.array(a[j])
            ra += c[j]
        if min(r) >= x:
            ans = min(ans, ra)
        return
    b = s.copy()
    nb = s.copy()
    b.append(0)
    nb.append(1)
    dfs(b)
    dfs(nb)

dfs([])
if ans == 10**5 + 1:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from itertools import combinations

N,M,X = map(int,input().split())
CA = [list(map(int,input().split())) for _ in range(N)]
A=[0]*(M+1)

ans=0

for i in range(N):
    ans+=CA[i][0]
    for j in range(1,M+1):
        A[j]+=CA[i][j]


for i in range(1,M+1):
    if A[i] <X:
        print(-1)
        sys.exit()


for i in range(1,N+1):
    for e in combinations(range(N),i):
        c = 0
        A = [0]*M
        for f in e:
            c += CA[f][0]
            for j in range(M):
                A[j] += CA[f][j+1]
    if min(A) >= X:
        ans = min(ans,c)
        
else:
    print(ans)

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):#行
    bit = [0]*N#行
    for j in range(N):#行
        state = [0] * M#列
        if (i >> j) & 1:
            bit[j] = 1
    #print(bit)
    #1の時全てのANを足し合わせる。合計金額を出す
    for k in range(N):
        if bit[k] == 1:
            for l in range(M):
                state[l] += c_A[k][l+1]
            total += c_A[k][0]
    
    #print(state)
    #print(total)
    for m in range(M):
        if state[m] < X:
            total = 0
            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:
import numpy as np
# dfsで全探索
n, m, x = map(int, input().split())
c = []
a = np.zeros((n, m))
for i in range(n):
    ll = list(map(int, input().split()))
    c.append(ll[0])
    a[i] += np.array(ll[1:])
    

ans = 10**5  + 1
# 0: Not Buy 1: Buy
s = []

def dfs(s):
    global ans
    if len(s) == n:
        r = np.zeros(m)
        ra = 0
        for j, k in enumerate(s):
            if k == 0:
                continue
            r += np.array(a[j])
            ra += c[j]
        if sum(r >= x) == m:
            ans = min(ans, ra)
        return
    b = [bb for bb in s]
    nb = [bb for bb in s]
    b.append(0)
    nb.append(1)
    dfs(b)
    dfs(nb)

dfs([])
if ans == 10**5 + 1:
    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**20

    for i in range(1, 2**n):
        #inBit = bin(i)[2:][::-1]
        inBit = ''.join(['{:0', str(n), 'b}']).format(i)[::-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**20:
        print(-1)
    else:
        print(minCost)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
from itertools import combinations

N,M,X = map(int,input().split())
CA = [list(map(int,input().split())) for _ in range(N)]
A=[0]*(M+1)

for i in range(N):
    for j in range(1,M+1):
        A[j]+=CA[i][j]

for i in A:
    if i <X:
        print(-1)
        sys.exit()

ans=sum(A)

for i in range(1,N+1):
    for e in combinations(range(N),i):
        c = 0
        A = [0]*(M+1)
        for f in e:
            c += CA[f][0]
            for j in range(M):
                A[i] += CA[f][j+1]
        if min(A) >= X:
            ans = min(ans,c)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N,M,X=map(int,input().split())
A=[[]for i in range(N+1)]
ans=10**6
for i in range(N):
    A[i]=(list(map(int,input().split())))
A=np.array(A)
#print(A)
for i in range(1,2**N):
    B=np.zeros(M+1)
    for j in range(N):
        if ((i >> j) & 1):
            B+=A[j]
    #print(B)
    if ans>=B[0] and X<=np.amin(B[1:]) :
        ans=B[0]
if ans==10**6:
    print(-1)
    exit()
else:
    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)]

min_money = 10 ** 5 * 12 + 1

for bits in range(1 << N):
    money = 0
    algo = [0] * M
    for i in range(N):
        if bits >> i & 1 == 1:
            money += books[i][0]
            for j in range(M):
                algo[j] += books[i][j + 1]

    if min(algo) >= X:
        min_money = min(min_money, money)

print(min_money)

Submission status: Wrong Answer

Solution code:
import sys
from itertools import product

n, m, x = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
min = sys.maxsize
for bit in product([False, True], repeat=n):
    ans = 0
    sum = 0
    for j in range(1, m + 1):
        for i in range(n):
            if bit[i]:
                sum += a[i][j]
        if sum < x:
            break
    if sum >= x:
        for i in range(n):
            if bit[i]:
                ans += a[i][0]
        if min > ans:
            min = ans
print(-1 if min == sys.maxsize else min)

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**20

    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**20:
        print(-1)
    else:
        print(minCost)

if __name__ == '__main__':
    main()

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**20

    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:
# coding: utf-8
# Your code here!
n,m,x=map(int,input().split())
A=[]
ALL=[]
ans=10**7
for i in range(n):
    A.append(list(map(int,input().split())))
for i in range(2**n):
    S=[0 for _ in range(m+1)]
    buy=[]
    for j in range(n):
        if ((i>>j) & 1):
            buy.append(A[j])
        #for k in range(m+1):
    for j in range(m+1):
        for k in range(len(buy)):
            S[j]+=buy[k][j]
    #print(S)
    flag=0
    for j in range(1,m+1):
        if S[j]<x:
            flag=1
    if flag==0:
        ans=min(ans,S[0])
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import numpy as np

def combinations(iterable, r):
    # combinations('ABCD', 2) --> AB AC AD BC BD CD
    # combinations(range(4), 3) --> 012 013 023 123
    pool = tuple(iterable)
    n = len(pool)
    if r > n:
        return
    indices = list(range(r))
    yield tuple(pool[i] for i in indices)
    while True:
        for i in reversed(range(r)):
            if indices[i] != i + n - r:
                break
        else:
            return
        indices[i] += 1
        for j in range(i+1, r):
            indices[j] = indices[j-1] + 1
        yield tuple(pool[i] for i in indices)

def main():

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

    l= []

    for i in range(n):
        for pair in combinations(matrix, i+1):
            row_sum = np.sum(pair, axis=0)
            for j in range(len(row_sum)):
                if j == 0:
                    continue
                if row_sum[j] < x:
                    break
                l.append(row_sum[0])
    if len(l) == 0:
        print('-1')
    else:
        print(min(l))


if __name__ == '__main__':
    main()

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:
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:
n, m, x = map(int, input().split())
prace = []
know = []
for i in range(n):
    acc = list(map(int, input().split()))
    prace.append(acc[0])
    know.append(acc[1:])

ans = 10**10
for i in range(2**n):
    und = [0 for i in range(m)]
    f = "{:b}".format(i)
    s = f.zfill(n)
    mm = 0
    print(s)
    for j in range(len(s)):
        if s[j] == '1':
            for k in range(m):
                und[k] += know[j][k]
            mm += prace[j]
    for j in range(m):
        if und[j] < x:
            break
    else:
        ans = min(ans, mm)
if ans == 10**10:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import itertools


def m():
    N, M, X = map(int, input().split())
    CA = [list(map(int, input().split())) for _ in range(N)]
    ans = float('inf')
    for i in itertools.product([True, False], repeat=N):
        tmp = [0] * (M + 1)
        for j, v in enumerate(i):
            if j:
                for k in range(M + 1):
                    tmp[k] += CA[j][k]
        f = 1
        for p in range(1, M + 1):
            if tmp[p] < X: f = 0
        if f: ans = min(ans, tmp[0])
    return ans if ans != float('inf') else "-1"


print(m())

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M, X = map(int, input().split())
C = []
A = np.zeros((N, M), dtype=int)
for i in range(N):
    c, *a = map(int, input().split())
    C.append(c)
    A[i] = a

S = np.sum(A, axis=0)
print(A)
print(S)
if True in (S < X):
    print(-1)
    exit(0)

mlt = [0]*12
C_ = []
for i in range(2**N):
    total = 0
    arr = np.zeros((M,),dtype=int)
    for j in range(N):
        if ((i>>j) & 1) == 1:
            total += C[j]
            arr += A[j]
    if True in (arr < X):
        continue
    C_.append(total)
print(min(C_))

Submission status: Wrong Answer

Solution code:
n, m, x = map(int,input().split(' '))
a = [[] for i in range(n)]
p = 0
for i in range(n):
    a[i] = list(map(int, input().split(' ')))
sc = 12 * 100001
for i in range(1, 2 ** n):
    bi = '0' * n + bin(i)[2:]
    bi = bi[len(bi) - n:]
    cc = 0
    e = [0] * m
    for j in range(n):
        if bi[j] == '1':
            for k in range(m):
                e[k] += a[j][k + 1]
            cc += a[j][0]
    su =True
    for j in range(m):
        su &= e[j] >= x
    if su:
        sc = min(sc, cc)
sc = -1 if sc > 12 * 100001 else sc
print(sc)

Submission status: Wrong Answer

Solution code:
n, m, x = map(int,input().split(' '))
a = [[] for i in range(n)]
p = 0
for i in range(n):
    a[i] = list(map(int, input().split(' ')))
sc = 999999999999
for i in range(1, 2 ** n):
    bi = '0' * n + bin(i)[2:]
    bi = bi[len(bi) - n:]
    cc = 0
    e = [0] * m
    for j in range(n):
        if bi[j] == '1':
            for k in range(m):
                e[k] += a[j][k + 1]
            cc += a[j][0]
    su =True
    for j in range(m):
        su &= e[j] >= x
    if su:
        sc = min(sc, cc)
sc = -1 if sc > 1000000 else sc
print(sc)

Submission status: Wrong Answer

Solution code:
n, m, x = map(int,input().split(' '))
a = [[] for i in range(n)]
p = 0
for i in range(n):
    a[i] = list(map(int, input().split(' ')))
sc = 999999
for i in range(1, 2 ** n):
    bi = '0' * n + bin(i)[2:]
    bi = bi[len(bi) - n:]
    cc = 0
    e = [0] * m
    for j in range(n):
        if bi[j] == '1':
            for k in range(m):
                e[k] += a[j][k + 1]
            cc += a[j][0]
    su =True
    for j in range(m):
        su &= e[j] >= x
    if su:
        sc = min(sc, cc)
sc = -1 if sc > 100000 else sc
print(sc)

Submission status: Wrong Answer

Solution code:
import math
import copy
from queue import Queue
import heapq
import numpy as np

MOD = 1000000007

#n = int(input())
#b = int(input())
n, m, x = [int(i) for i in input().split()]
table = [[int(i) for i in input().split()] for j in range(n)]
#table = [list(input()) for n in range(h)]
#s = [int(i) for i in input().split()]
#s = [int(i) for i in range(n)]
#s = [int(input()) for i in range(n)]
#s = input()
#list = list(s)
# dp = [[0 for _ in range(2)] for _ in range(13)]
#dp = [[[0 for _ in range(11)] for _ in range(2)] for _ in range(11)]

#a = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

min = 1200000
for i in range (2 ** n):
    flag = 1
    for k in range(1,m+1):
        temp = 0
        cost = 0
        for l in range(0,n):
            mask = 1 << l
            if (i & mask):
                temp += table[l][k]
                cost += table[l][0]
        if (temp < x) :
            flag = 0
    if(flag == 1 and min > cost):
        min = cost


if (min == 1200000):
    print("-1")
else:
    print(min)

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
l = [list(map(int,input().split())) for i in range(n)]
 
ans = 0
 
for i in range(2**n):
    count = [0]*m
    c = 0
    for j in range(n):
        if (i >> j) & 1:
            c += l[j][0]
            for k in range(1,m+1):
                count[k-1] += l[j][k]
    check = True
    for j in count:
        if j < x:
            check = False
            break
    if check:
        ans = min(ans,c)
if ans == 0:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
n, m, x = map(int,input().split(' '))
a = [[] for i in range(n)]
p = 0
for i in range(n):
    a[i] = list(map(int, input().split(' ')))
sc = 999999
for i in range(1, pow(2, n)):
    bi = '0' * n + bin(i)[2:]
    bi = bi[len(bi) - n:]
    cc = 0
    e = [0] * m
    for j in range(n):
        if bi[j] == '1':
            for k in range(m):
                e[k] += a[j][k + 1]
            cc += a[j][0]
    su =True
    for j in range(m):
        su &= e[j] >= x
    sc = min(sc, cc) if su else sc
sc = -1 if sc > 100000 else sc
print(sc)

Submission status: Wrong Answer

Solution code:
# 初期入力
from itertools import combinations
import math
import numpy as np 
import sys
input = sys.stdin.readline
N,M,X = (int(x) for x in input().split())
C = [list(map(int, input().split())) for i in range(N)]
all_per =[i for i in range(N)]

price_list =[]
price_sum=0
k=0
flag =False
underst =np.array(C,dtype=int)
price =underst[:,0]
understanding =np.delete(underst,0,1)


for num in range(1,N+1):
    for t in combinations(all_per,num): #参考書を買う組合せを1冊からN冊まで全列挙
        book_buy =np.array(t,dtype=int)
        understanding_now =understanding[book_buy]
        understanding_sum =np.sum(understanding_now,axis=0)
        price_sum=0
        k=0
        if np.all(X <= understanding_sum ): #アルゴリズム理解度が全て目標値X以上か
            price_now =price[book_buy]
            price_list.append(np.sum(price_now))
            flag =True
            break
if flag ==True:
    print(min(price_list))
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]
    else:
        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])

Submission status: Wrong Answer

Solution code:
n, m, x = map(int,input().split(' '))
a = [[] for i in range(n)]
p = 0
for i in range(n):
    a[i] = list(map(int, input().split(' ')))
sc = 100001
for i in range(1, pow(2, n)):
    bi = '0' * n + bin(i)[2:]
    bi = bi[len(bi) - n:]
    cc = 0
    e = [0] * m
    for j in range(n):
        if bi[j] == '1':
            for k in range(m):
                e[k] += a[j][k + 1]
            cc += a[j][0]
    su =True
    for j in range(m):
        su &= e[j] >= x
    sc = min(sc, cc) if su else sc
sc = -1 if sc > 100000 else sc
print(sc)

Submission status: Wrong Answer

Solution code:
n, m, x = map(int,input().split(' '))
a = [[] for i in range(n)]
p = 0
for i in range(n):
    a[i] = list(map(int, input().split(' ')))
sc = 100001
for i in range(1, pow(2, n)):
    bi = '0' * n + bin(i)[2:]
    bi = bi[len(bi) - n:]
    cc = 0
    e = [0] * m
    for j in range(n):
        if bi[j] == '1':
            su = True
            for k in range(m):
                e[k] += a[j][k + 1]
                su &= e[k] >= x
            cc += a[j][0]
    sc = min(sc, cc) if su else sc
sc = -1 if sc > 100000 else sc
print(sc)

Submission status: Wrong Answer

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

# print(c_)
cc_ = []
for i in range(n):
    cc_.append(c_[i][0])
# print(cc_)

import numpy as np
import itertools
l_ = np.arange(n).tolist()

res_ = []
resList = []
flag = False
flag3 = True
if n == 1:
    for i in range(m):
        if c_[0][i+1] < x:
            # print(c_[0][i+1])
            flag3 = False
    print(cc_[0] if flag3 else -1)
else:
    for i in range(2,n+1):
        c = list(itertools.combinations(l_, i))
        for j in c:
            res_ = []
            flag2 = True
            for l in range(m):
                res = 0
                sum_money = 0
                for k in range(len(j)):
                    res += c_[j[k]][l+1]
                    sum_money += c_[j[k]][0]
                # print(res,sum_money)
                if res < x:
                    flag2 = False
            if flag2:
                resList.append(sum_money)
                flag = True
    # print(resList)
    print(min(resList) if flag else -1)

Submission status: Wrong Answer

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

# print(c_)
cc_ = []
for i in range(n):
    cc_.append(c_[i][0])
# print(cc_)

import numpy as np
import itertools
l_ = np.arange(n).tolist()

res_ = []
resList = []
flag = False

if n == 1:
    flag3 = True
    for i in range(m):
        if c_[0][i+1] < x:
            flag = False
    print(cc_[0] if flag3 else -1)
else:
    for i in range(2,n+1):
        c = list(itertools.combinations(l_, i))
        for j in c:
            res_ = []
            flag2 = True
            for l in range(m):
                res = 0
                sum_money = 0
                for k in range(len(j)):
                    res += c_[j[k]][l+1]
                    sum_money += c_[j[k]][0]
                # print(res,sum_money)
                if res < x:
                    flag2 = False
            if flag2:
                resList.append(sum_money)
                flag = True
    # print(resList)
    print(min(resList) if flag else -1)