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
import itertools
N,M,X=map(int,input().split())
C=[]
A=[]
for i in range(N):
	arr=input().split()
	C.append(arr[0])
	A.append(arr[1:M+1])

C=np.array(C,dtype=int)
A=np.array(A,dtype=int)
count=np.sum(A,axis=0)
if np.any(count<X):
	print(-1)
else:
	l=[int(i) for i in range(N)]
	result = []
	syuturyoku=10**5
	for n in range(1,N+1):
		for conb in itertools.combinations(l, n):
			result.append(list(conb)) #タプルをリスト型に変換
	for i in range(len(result)):
		count2=np.zeros(M)
		count3=0
		for j in result[i]:
			count2+=A[j]
			count3+=C[j]
		if np.all(count2>=X):
			if syuturyoku>count3:
				syuturyoku=count3
	print(syuturyoku)

Submission status: Wrong Answer

Solution code:
from itertools import combinations

def python_list_add(in1, in2):
   return list(map(sum, zip(in1, in2)))

N, M, X = map(int, input().split())
T = []
C = []

for n in range(N):
    C.append(list(map(int, input().split())))


for l in range(1, N):
    T += combinations(range(N),l)

#print(T)
Min = 1000000000
f = True
for t in T:
    Sam = [0] * (M+1)
    for i in t:
        #print(i)
        for m in range(M+1):
            Sam[m] = Sam[m] + C[i][m]
        if Sam[0] > Min:
            #print('over')
            break
    #print(Sam)
    F = False
    for z in range(1,M+1):
        #print(Sam)
        if Sam[z] < X:
            #print('not enough')
            F = True
            break
    if F == False and Sam[0] < Min:
        Min = Sam[0]
        #print('Min:', str(Min))
        f = False
if f:
    print('-1')
else:
    print(Min)

Submission status: Wrong Answer

Solution code:
from itertools import combinations

def python_list_add(in1, in2):
   return list(map(sum, zip(in1, in2)))

N, M, X = map(int, input().split())
T = []
C = []

for n in range(N):
    C.append(list(map(int, input().split())))


for l in range(1, N):
    T += combinations(range(N),l)

#print(T)
Min = 10000000
f = True
for t in T:
    Sam = [0] * (M+1)
    for i in t:
        #print(i)
        for m in range(M+1):
            Sam[m] = Sam[m] + C[i][m]
        if Sam[0] > Min:
            #print('over')
            break
    #print(Sam)
    F = False
    for z in range(1,M+1):
        #print(Sam)
        if Sam[z] < X:
            #print('not enough')
            F = True
            break
    if F == False and Sam[0] < Min:
        Min = Sam[0]
        #print('Min:', str(Min))
        f = False
if f:
    print('-1')
else:
    print(Min)

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
bk = [list(map(int, input().split())) for _ in range(n)]
pr = 10 ** 7
for i in range(2 ** n):
    ef = [0] * (m + 1)
    for j in range(n):
        if i >> j & 1:
            ef = [p + q for (p, q) in zip(ef, bk[j])]
    for k in range(1, m + 1):
        if ef[k] < x:
            break
        if k == m:
            pr = min(pr, ef[0])
print(pr if pr != 10 ** 6 else -1)

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
bk = [list(map(int, input().split())) for _ in range(n)]
pr = 10 ** 6
for i in range(2 ** n):
    ef = [0] * (m + 1)
    for j in range(n):
        if i >> j & 1:
            ef = [p + q for (p, q) in zip(ef, bk[j])]
    for k in range(1, m + 1):
        if ef[k] < x:
            break
        if k == m:
            pr = min(pr, ef[0])
print(pr if pr != 10 ** 6 else -1)

Submission status: Wrong Answer

Solution code:
def mapt(fn, *args):
    return tuple(map(fn, *args))

n, m, x = mapt(int, input().split(" "))
c = [mapt(int, input().split(" ")) for _ in range(n)]

ans = float("inf")
count = 0
for i in range(1<<n):
    temp = []
    temp2 = []
    for j in range(n):
        # print(i, bin(i), i>>j&1, j)
        temp.append(i>>j&1)
        if i>>j&1 == 1:
            # print(c[j])
            temp2.append(c[j])
    count += 1

    data = list(zip(*temp2))
    if not data: continue
    cost_sum = sum(data[0])
    cost_rest= [sum(row)>=x for row in data[1:]]
    # print(cost_sum, cost_rest)
    if all(cost_rest) and cost_sum >= x:
      ans = min(ans, cost_sum)
      
if ans == float("inf"): print(-1)
else: print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import product
import numpy as np

n, _, x = map(int, input().split())
arr1 = np.array([list(map(int, input().split())) for _ in range(n)])
ans = 120000
if np.all(arr1.sum(0)[1:] >= x):
    for i in product((0, 1), repeat=n):
        arr2 = ((i * arr1.T).T).sum(0)
        if np.all(arr2[1:] >= x):
            ans = min(ans, arr2[0])
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

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

c = [0]*n
a = [0]*n

for i in range(n):
    c[i],a[i] = ca[i][0],ca[i][1:]

INF = 10**6
ans  = INF

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

if ans == INF:
    ans = -1

print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
N, M, X = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
flug = True
for j in range(1, M + 1):
    sum_test = 0
    for i in range(N):
        sum_test += A[i][j]
    if sum_test < X:
        flug = False
        break
N_idx = [n for n in range(N)]
rec_tes = 0
for i in range(N):
    rec_tes += A[i][0] 
for i in range(N):
    for j in combinations(N_idx, r = i + 1):
        for k in range(1, M + 1):
            sum_und = 0
            sum_tes = 0
            for h in j:
                sum_und += A[h][k]
                sum_tes += A[h][0]
            if sum_und < X:
                break
        if sum_tes != 0 and sum_tes < rec_tes:
            rec_tes = sum_tes
if flug:
    print(rec_tes)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
N, M, X = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
flug = True
for j in range(1, M + 1):
    sum_test = 0
    for i in range(N):
        sum_test += A[i][j]
    if sum_test < X:
        flug = False
        break
N_idx = [n for n in range(N)]
rec_tes = 0
for i in range(N):
    rec_tes += A[i][0] 
for i in range(N):
    for j in combinations(N_idx, r = i + 1):
        for k in range(1,M+1):
            sum_und = 0
            sum_tes = 0
            for h in j:
                sum_und += A[h][k]
                sum_tes += A[h][0]
            if sum_und < X:
                break
            if sum_tes != 0 and sum_tes < rec_tes:
                rec_tes = sum_tes
if flug:
    print(rec_tes)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
ans=[]
for i in range(2**n):
    bag=[0 for _ in range(m)]
    total=0
    res=True
    for j in range(n):
        if ((i>>j)&1):
            total+=a[j][0]
            for k in range(m):
                bag[k]+=a[j][k-1]
    for l in range(m):
        if bag[l]<x:
            res=False
            break
    if res:
        ans.append(total)

if ans!=[]:
    print(min(ans))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np

N,M,X = map(int,input().split())
ca=np.array([0]*(M+1))
ans = 10**7

for i in range(N):
    ca=np.vstack([ca,[int(i) for i in input().split()]])

for i in range(2**N):

    need_skills=np.array([0]+[X]*M)

    buy_item = [0]*N
    for j in range(N):
        if (i>>j)&1:
            buy_item[j]=1

    print("buy_item",buy_item)
    for k in range(N):
        need_skills -= ca[k+1]*buy_item[k]

    print(need_skills)
    if np.all(need_skills<=0):
        ans = min(ans,-need_skills[0])

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

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
a = [0]*n
for i in range(n):
    a[i] = list(map(int,input().split()))
ans = float("Inf")
for i in range(2**n):
    c = 0
    L = [0]*m
    for j in range(n):
        if (i>>j)&1:
            c += a[j][0]
            for k in range(m):
                L[k] += a[j][k]
    
    sw = 1
    for k in range(m):
        if L[k] < x:
            sw = 0
            break
    if sw == 1:
        ans = min(ans, c)
        
if ans == float("Inf"):
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    n,m,x = map(int,input().split())
    c = []
    a = []
    for _ in range(n):
        ca = [int(v) for v in input().split()]
        c.append(ca[0])
        a.append(ca[1:])
    
    INTHIGH = 1<<15
    pricemin = INTHIGH
    for i in range(1<<n):
        sm = [0]*m
        sc = 0
        for j in range(n):
            if i & 1<<j:
                sc += c[j]
                for k in range(m):
                    sm[k] += a[j][k]
                if min(sm)>=x:
                    pricemin = min(pricemin, sc)
                    break

    print(pricemin if pricemin<INTHIGH else -1) 

main()

Submission status: Wrong Answer

Solution code:
def main():
    n,m,x = map(int,input().split())
    c = []
    a = []
    for _ in range(n):
        ca = [int(v) for v in input().split()]
        c.append(ca[0])
        a.append(ca[1:])
    
    pricemin = 1<<15
    for i in range(1<<n):
        sm = [0]*m
        sc = 0
        for j in range(n):
            if i & 1<<j:
                sc += c[j]
                for k in range(m):
                    sm[k] += a[j][k]
                if min(sm)>=x:
                    pricemin = min(pricemin, sc)
                    break

    print(pricemin) 

main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
def main():
    import sys

    input = sys.stdin.readline

    N, M, X = map(int, input().split())
    A = []
    for i in range(N):
        a = [int(x) for x in input().split()]
        A.append(a)

    ans = 10 ** 7
    for bit in range(1 << N):
        res = [0 for _ in [0] * M]
        for i in range(N):
            if bit & (1 << i):
                res = [a + b for a, b in zip(res, A[i])]
        if all(a >= X for a in res[1:]):
            ans = min(ans, res[0])
    if ans == 10 ** 7:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
A = [[] for i in range(m)]
eff = [[] for i in range(m)]
price = []
for a in range(n):
    a = list(map(int, input().split()))
    price.append(a[0])
    for j in range(m):
        A[j].append(a[j+1])


for a in A:
    if sum(a) < x:
        print(-1)
        exit()

min_money = 0

min_for_i = 1<<30
for bits in range(1<<n):
    sum_temp = [0] * m
    sum_money = 0
    for j in range(n):
        if bits>>j & 1:
            sum_money += price[j]
            for i in range(m):
                sum_temp[i] += A[i][j]
    else:
        for i in sum_temp:
            if i < x:
                break
            min_for_i = min(min_for_i, sum_money)
min_money += min_for_i


print(min_money)

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
s=[]
c=[]
a=[]
for i in range(n):
    l=list(map(int,input().split()))
    s.append(l)

s.sort()
s.reverse()
ans=0
for i in range(n):
    c.append(s[i][0])
    a.append(s[i][1:])
    ans+=s[i][0]


sum=[0]*m
flag=True

for i in range(m):
    for j in range(n):
        sum[i]+=a[j][i]
    if sum[i]<x:
        flag=False  

if flag:
    for i in range(n):
        flag2=True
        for j in range(m):
            if sum[j]-a[i][j]<x:
                flag2=False
                break
        if flag2:
            for j in range(m):
                sum[j]-=a[i][j]
            ans-=c[i]
else:
    ans=-1
print(ans)

Submission status: Wrong Answer

Solution code:
N,M,X = map(int,input().split())
C = []
A = []
for i in range(N):
    L = list(map(int,input().split()))
    C.append(L[0])
    A.append(L[1:M+1])
import itertools
L = []
Num = [i for i in range(N)]
for i in range(1,N+1):
    for j in itertools.combinations(Num,i):
        L.append(list(j))
c = 20000000
for i in range(len(L)):
    Z = [0 for _ in range(M)]
    m = 0
    for j in range(len(L[i])):
        for k in range(M):
            Z[k] += A[L[i][j]][k]
        m += C[L[i][j]]
    for l in range(M):
        if Z[l] < X:
            break
        if l == M-1:
            c = min(c,m)
if c == 200000:
    print(-1)
else:
    print(c)

Submission status: Wrong Answer

Solution code:
N,M,X = map(int,input().split())
C = []
A = []
for i in range(N):
    L = list(map(int,input().split()))
    C.append(L[0])
    A.append(L[1:M+1])
import itertools
L = []
Num = [i for i in range(N)]
for i in range(1,N+1):
    for j in itertools.combinations(Num,i):
        L.append(list(j))
c = 200000
for i in range(len(L)):
    Z = [0 for _ in range(M)]
    m = 0
    for j in range(len(L[i])):
        for k in range(M):
            Z[k] += A[L[i][j]][k]
        m += C[L[i][j]]
    for l in range(M):
        if Z[l] < X:
            break
        if l == M-1:
            c = min(c,m)
if c == 200000:
    print(-1)
else:
    print(c)

Submission status: Wrong Answer

Solution code:
import itertools
n,m,x=map(int, input().split())
a = [list(map(int, input().split())) for l in range(n)]
bit=list(itertools.product([0,1],repeat=n))
M=10**6
for i in range(2**n):
  cnt1=[0]*m
  cnt2=0
  for j in range(n):
    if bit[i][j]==1:
      cnt2+=a[j][0]
      for k in range(m):
        cnt1[k]+=a[j][k+1]
  ans=True
  for j in range(m):
    if cnt1[j]<x:
      ans=False
  if ans:
    M=min(cnt2,M)
if M==10**6:
  print(-1)
else:
  print(M)

Submission status: Wrong Answer

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

N=[]
NI=[]
for i in range(n) :
    N = list(map(str, input().split()))
    NI.append(N)

ans=-1

for i in range(1<<n) :
    A=[0]*(m+1)
    for j in range(n) :
        # print(NI[j])
        if (1<<j)&i :
            A=[x+int(y) for(x,y)in zip(A,NI[j])]
    print(A)
    a = A[0]
    del A[0]
    if min(A)<x :
        a=-1
    elif ans==-1:
        ans = a
    elif ans>a :
        ans = a
print(ans)

Submission status: Wrong Answer

Solution code:
import math
def facts(n):
    ans = []
    for  i in range(1, int(math.sqrt(n)+1)):
        if(n%i==0):
            ans.append(i)
            ans.append(n//i)
    ans = sorted(ans)
    return ans


n,m, x = map(int, input().split())
arr = []
narr = [0 for i in range(m)]
ans = int(10e5)+1
for i in range(n):
    tarr = list(map(int, input().split()))
    arr.append(tarr)
for i in range(1<<n):
    tarr = list(narr)
    cost = 0
    for a in range(n):
        if((i>>a)&1):
            cost+=arr[a][0]
            for b in range(1, m+1):
                tarr[b-1] += arr[a][b]
    ok = True
    for i in range(m):
        if(tarr[i]<x):
            ok = False
            break
    if(ok):
        ans = min(ans, cost)
if(ans == int(10e5)+1):
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Sum = [0] * (m + 1)
mincost = 0x7fffffff

for bit in range(2**n):
	tmpcost = 0
	Sum = [0] * (m + 1)
	flag = False
	for i in range(n):
		if ((bit >> i) & 1):
			tmpcost += a[i][0]
			for j in range(1 , m + 1):
				Sum[j] += a[i][j]
	for i in range(1 , m + 1):
		if x > Sum[i]:
			flag = True
			break
	if flag == False:
		mincost = min(mincost , tmpcost)

if mincost != 0x7ffffff:
	print(mincost)
else:
	print(-1)

Submission status: Wrong Answer

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

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

Sum = [0] * (m + 1)
mincost = 0x7ffffff

for bit in range(2**n):
	tmpcost = 0
	Sum = [0 for _ in Sum]
	flag = False
	for i in range(n):
		if ((bit >> i) & 1):
			tmpcost += a[i][0]
			for j in range(1 , m):
				Sum[j] += a[i][j]
	for i in range(1 , m):
		if x > Sum[i]:
			flag = True
			break
	if flag == False:
		mincost = min(mincost , tmpcost)

if mincost != 0x7ffffff:
	print(mincost)
else:
	print(-1)

Submission status: Wrong Answer

Solution code:
scnum = list(map(int,input().split()))
score = [0]*scnum[0]
answer = 12*(10**5)
nowsum = 0
scosum = [0]*scnum[1]
gacchi = 0

for i in range(scnum[0]):
    score[i] = list(map(int,input().split()))
    
for j in range(2**scnum[0]):
    if j != 0:
        for h in range(scnum[0]):
            if (j>>h) & 1:
                nowsum += score[h][0]
                for k in range(scnum[1]):
                    scosum[k] += score[h][k+1]
        for l in range(scnum[1]):
            if scosum[l] >= scnum[2]:
                gacchi += 1
        if gacchi == scnum[1] and nowsum < answer:
            answer = nowsum
        nowsum = 0
        gacchi = 0
        scosum = [0]*scnum[1]

if answer == 12*(10**5):
    print(-1)
else:
    print(answer)

Submission status: Wrong Answer

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

for i in range(2**N):
    total_skill=[0,0,0,0]
    for j in range(N):
        if ((i>>j) & 1):
            total_skill = [x+y for (x,y) in zip(total_skill,skill[j])]
    count=0
    for k in total_skill[1:]:
        if k<X:
            count +=1
    if count==0:
        cost.append(total_skill[0])

cost.sort()
print(-1 if cost==[] else cost[0])

Submission status: Wrong Answer

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

for i in range(2**N):
    total_skill=[0,0,0,0]
    for j in range(N):
        if ((i>>j) & 1):
            total_skill = [x+y for (x,y) in zip(total_skill,skill[j])]
    count=0
    print(i,"回目")
    print(total_skill)
    for k in total_skill[1:]:
        print(k)
        if k<X:
            count +=1
    if count==0:
        cost.append(total_skill[0])

cost.sort()
print(-1 if cost==[] else cost[0])

Submission status: Wrong Answer

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

for i in range(2**N):
    total_skill=[0,0,0,0]
    for j in range(N):
        if ((i>>j) & 1):
            total_skill = [x+y for (x,y) in zip(total_skill,skill[j])]
        count=0
        
        for k in total_skill[1:]:
            if k<X:
                count +=1
        if count==0:
            cost.append(total_skill[0])
cost.sort()
print(-1 if cost==[] else cost[0])

Submission status: Wrong Answer

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

for i in range(2**N+1):
    total_skill=[0,0,0,0]
    for j in range(N):
        if ((i>>j) & 1):
            total_skill = [x+y for (x,y) in zip(total_skill,skill[j])]
        count=0
        for k in total_skill[1:]:
            if k<X:
                count +=1
        if count==0:
            cost.append(total_skill[0])
cost.sort()
print(-1 if cost==[] else cost[0])

Submission status: Wrong Answer

Solution code:
n,m,x = list(map(int,input().split()))

cList = []

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

#buyList = [0 for  i in range(n)]
priceList = []
for i in range(1,2**n):
    price = 0
    check = 1
    skilList = [0 for  i in range(m)]
    bit = i
    for j in range(1,n+1):
        if bit % 2 == 1:
            #buyList[j-1] = 1
            price += cList[j-1][0]
            for k in range(m):
                skilList[k] = skilList[k] + cList[j-1][k]
        bit = bit // 2
    for j in skilList:
        if j < x:
            check = 0
            break
    if check == 1:
        priceList.append(price)

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m,x = map(int,input().split())
value = []
books = []
for i in range(n):
    a = list(map(int,input().split()))
    value.append(a[0])
    books.append(np.array(a[1:]))
if min(sum(books))<x:
    print(-1)
else:
    ans = 10**6
    for i in range(2**n):
        M = np.array([0]*m)
        v = 0
        for j in range(n):
            if i >> j & 1:
                M += books[j]
                v += value[j]
        if min(M)>= x:
            ans = min(ans,v)
    print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
N, M, X = map(int, input().split())
C = [0] * N
A = [0] * N
for i in range(N):
    x = list(map(int, input().split()))
    C[i] = x[0]
    A[i] = [0] * M
    for j in range(M):
        A[i][j] = x[j + 1]
cnt = [0] * (2 ** N)
ans_list = []
for i in range(2 ** N):
    bag = []
    cnt[i] = [0] * M
    for j in range(N):
        if ((i >> j) & 1):
            bag.append(C[j])
            for k in range(M):
                cnt[i][k] += A[j][k]
    if bisect.bisect_left(cnt[i], X) == 0:
        ans_list.append(sum(bag))
if ans_list == []:
    print(-1)
else:
    print(min(ans_list))

Submission status: Wrong Answer

Solution code:
import bisect
N, M, X = map(int, input().split())
C = [0] * N
A = [0] * N
for i in range(N):
    x = list(map(int, input().split()))
    C[i] = x[0]
    A[i] = [0] * M
    for j in range(M):
        A[i][j] = x[j + 1]
cnt = [0] * (2 **N)
ans_list = []
for i in range(2 ** N):
    bag = []
    cnt[i] = [0] * M
    for j in range(N):
        if ((i >> j) & 1):
            bag.append(C[j]) 
            for k in range(M):
                cnt[i][k] += A[j][k]
    if bisect.bisect_left(cnt[i], X) == 0:
        ans_list.append(sum(bag))
if ans_list == []:
    print(-1)
else:
    print(min(ans_list))

Submission status: Wrong Answer

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

A = [list(map(int, input().split())) for j in range(n)]
ans = 10 ** 7
for i in range(1 << n):
    s = [0] * (m + 1)
    for j in range(n):
        if i >> j & 1:
            for k in range(m+1):
                s[k] += A[j][k]
    if min(s[1:]) >= x:
        ans = min(ans, s[0])
print(-1) if ans == 10 ** 6 else print(ans)

Submission status: Wrong Answer

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

A = [list(map(int, input().split())) for j in range(n)]
ans = 10 ** 6
for i in range(1 << n):
    s = [0] * (m + 1)
    for j in range(n):
        if i >> j & 1:
            for k in range(m+1):
                s[k] += A[j][k]
    if min(s[1:]) >= x:
        ans = min(ans, s[0])
print(-1) if ans == 10 **6 else print(ans)

Submission status: Wrong Answer

Solution code:
import math

n, m, x = map(int, input().split())
books = []
for i in range(n):
    books.append(list(map(int, input().split())))
n_bin = '1'*n
_n = (int(n_bin, 2))
ans = 10**9
for i in range(_n):
    target = bin(i).replace('0b', '').zfill(n)
    tmp_skill = [0 for i in range(len(books[0])-1)]
    tmp_price = 0
    for j in range(len(target)):
        if target[j] == '1':
            tmp_price += books[j][0]
            for k in range(len(tmp_skill)):
                tmp_skill[k] += books[j][k+1]
        for k in range(len(tmp_skill)):
            if tmp_skill[k] < x:
                break
        else:
            ans = min(ans, tmp_price)
if ans == 10**9:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
# abc167_c.py
# https://atcoder.jp/contests/abc167/tasks/abc167_c

# C - Skill Up /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 300点

# 問題文
# 競技プログラミングを始めた高橋くんは、学びたいアルゴリズムが M個あります。 最初、各アルゴリズムの理解度は 0です。
# 高橋くんが書店に行くと、N冊の参考書が売っていました。
# i 番目の参考書 (1≤i≤N) は Ci 円で売られていて、購入して読むことで、各 j (1≤j≤M) について j 番目のアルゴリズムの理解度が Ai,j上がります。 
# また、それ以外の方法で理解度を上げることはできません。
# 高橋くんの目標は M個すべてのアルゴリズムの理解度を X以上にすることです。
# 高橋くんが目標を達成することが可能か判定し、可能な場合は目標を達成するのに必要な金額の最小値を計算してください。

# 制約
#     入力はすべて整数
#     1≤N,M≤12
#     1≤X≤105
#     1≤Ci≤105
#     0≤Ai,j≤105

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N M X
# C1 A1,1 A1,2 ⋯ A1,M
# C2 A2,1 A2,2 ⋯ A2,M
# ⋮
# CN AN,1 AN,2 ⋯ AN,M

# 出力
# 高橋くんが目標を達成できないならば -1 を、 そうでなければ目標を達成するのに必要な金額の最小値を出力せよ。

# 入力例 1
# 3 3 10
# 60 2 2 4
# 70 8 7 9
# 50 2 3 9

# 出力例 1
# 120

# 2,3番目の参考書を購入すると 120 円ですべてのアルゴリズムの理解度を 10以上にすることができ、これが最小値です。

# 入力例 2
# 3 3 10
# 100 3 1 4
# 100 1 5 9
# 100 2 6 5

# 出力例 2
# -1

# すべての参考書を購入しても 1つ目のアルゴリズムの理解度が 10に達しません。

# 入力例 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

# 出力例 3
# 1067


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    N, M, X = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    valueses = list()
    for i in range(N):
        valueses.append(list(map(int, lines[i+1].split())))

    result = 9999

    for i in range(2**N):
        pattern = format(int(format(i, 'b')), '0=' + str(N))
        # pattern = '11110100'
        cost = 0
        scores = [0] * M
        for n in range(N):
            # log(f'pattern[{n}]=[{pattern[n]}]')
            if pattern[n] == '1':
                cost += valueses[n][0]
                # log(f'cost=[{cost}]')
                for m in range(M):
                    scores[m] += valueses[n][m+1]
        log(f'scores=[{scores}]')
        flag = True
        # log(f'flag=[{flag}]')
        for m in range(M):
            if scores[m] < X:
                # log(f'scores[{m}]=[{scores[m]}]')
                flag = False
        log(f'flag=[{flag}]')
        log(f'min(scores)=[{min(scores)}]')
        if min(scores) >= X:
            log(f'if min(scores) >= X:, result=[{result}], cost=[{cost}], result > cost=[{result > cost}]')
            if result is None:
                result = cost
            elif result > cost:
                log(f'pattern=[{pattern}]')
                result = cost
        log(f'result=[{result}]')
        log(f'cost=[{cost}]')
        # exit()

    if result is None:
        result = -1

    return [result]


# 引数を取得
def get_input_lines():
    line = input()
    N, M, X = list(map(int, line.split()))
    lines = list()
    lines.append(line)
    for _ in range(N):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['3 3 10', '60 2 2 4', '70 8 7 9', '50 2 3 9']
        lines_export = [120]
    if pattern == 2:
        lines_input = ['3 3 10', '100 3 1 4', '100 1 5 9', '100 2 6 5']
        lines_export = [-1]
    if pattern == 3:
        lines_input = ['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']
        lines_export = [1067]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines()
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()