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
n,m,x = map(int,input().split())
all = []
cost = []
result = []
for i in range(n):
    tmp =list(map(int,input().split()))
    all.append(tmp[1:])
    cost.append(tmp[0])
# print(cost)
# print(all)
for i1 in range(m):
    for i2 in range(i1+1,n):
        sum = np.array(all[i1]) +np.array(all[i2])
        flag = True
        for i in sum:
            if(i < x):
                flag = False
        if(flag):
            result.append(cost[i1]+cost[i2])

#3
for i1 in range(n):
    for i2 in range(i1+1,n):
        for i3 in range(i2+1,n):
            sum = np.array(all[i1]) + np.array(all[i2]) + np.array(all[i3]) 
            flag = True
            for i in sum:
                if(i < x):
                    flag = False
            if(flag):
                result.append(cost[i1]+cost[i2]+cost[i3])
#4
for i1 in range(m):
    for i2 in range(i1+1,n):
        for i3 in range(i2+1,n):
                for i4 in range(i3+1,n):
                    sum = np.array(all[i1]) + np.array(all[i2]) + np.array(all[i3])+np.array(all[i4])
                    flag = True
                    for i in sum:
                        if(i < x):
                            flag = False
                    if(flag):
                        result.append(cost[i1]+cost[i2]+cost[i3]+cost[i4])
for i1 in range(m):
    for i2 in range(i1+1,n):
        for i3 in range(i2+1,n):
            for i4 in range(i3+1,n):
                for i5 in range(i4+1,n):
                    sum = np.array(all[i1]) + np.array(all[i2]) + np.array(all[i3])+np.array(all[i4])+np.array(all[i5])
                    flag = True
                    for i in sum:
                        if(i < x):
                            flag = False
                    if(flag):
                        result.append(cost[i1]+cost[i2]+cost[i3]+cost[i4]+cost[i5])
for i1 in range(m):
    for i2 in range(i1+1,n):
        for i3 in range(i2+1,n):
            for i4 in range(i3+1,n):
                for i5 in range(i4+1,n):
                    for i6 in range(i5+1,n):
                        
                        sum = np.array(all[i1]) + np.array(all[i2]) + np.array(all[i3])+np.array(all[i4])+np.array(all[i5])+np.array(all[i6])
                        
                        flag = True
                        for i in sum:
                            if(i < x):
                                flag = False
                        if(flag):
                            result.append(cost[i1]+cost[i2]+cost[i3]+cost[i4]+cost[i5]+cost[i6])
for i1 in range(m):
    for i2 in range(i1+1,n):
        for i3 in range(i2+1,n):
            for i4 in range(i3+1,n):
                for i5 in range(i4+1,n):
                    for i6 in range(i5+1,n):
                        for i7 in range(i6+1,n):
                            sum = np.array(all[i1]) + np.array(all[i2]) + np.array(all[i3])+np.array(all[i4])+np.array(all[i5])+np.array(all[i6])+np.array(all[i7])
                            flag = True
                            for i in sum:
                                if(i < x):
                                    flag = False
                            if(flag):
                                result.append(cost[i1]+cost[i2]+cost[i3]+cost[i4]+cost[i5]+cost[i6]+cost[i7])

for i1 in range(m):
    for i2 in range(i1+1,n):
        for i3 in range(i2+1,n):
            for i4 in range(i3+1,n):
                for i5 in range(i4+1,n):
                    for i6 in range(i5+1,n):
                        for i7 in range(i6+1,n):
                            sum = np.array(all[i1]) + np.array(all[i2]) + np.array(all[i3])+np.array(all[i4])+np.array(all[i5])+np.array(all[i6])+np.array(all[i7])
                            #print(i1,i2,i3,i4,i5,i6,i7,sum)
                            flag = True
                            for i in sum:
                                if(i < x):
                                    flag = False
                            if(flag):
                                result.append(cost[i1]+cost[i2]+cost[i3]+cost[i4]+cost[i5]+cost[i6]+cost[i7])
if(result ==[]):
    print(-1)
else:
    print(min(result))

Submission status: Wrong Answer

Solution code:
import numpy as np

def yn(t,x):
  for j in range(len(t)-1):
    if t[j+1] < x:
      return False
  return True
  
n,m,x=list(map(int,input().split()))
a=[]
for i in range(n):
  a.append(list(map(int,input().split())))
  
a=np.array(a)
for i in range(m):
  a=a[np.argsort(a[:,i+1])[::-1]]
a=a[np.argsort(a[:,0])]
t=np.sum(a,axis=0)

for i in range(1,n+1):
  if yn(t-a[-i],x):
    t = t-a[-i]

if not yn(t,x):
  print("-1")
else:
  print(t[0])

Submission status: Wrong Answer

Solution code:
import numpy as np

# スペース区切りの整数の入力
N, M, X = map(int, input().split())

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

Amat = np.array(A).reshape(N, M)

Am_sum = (np.sum(Amat,axis=0) > X )

if np.all(Am_sum):
    Bag = np.sum(Amat, axis=0) - X
    
     
    print("TODO")
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np

N, M, X = map(int, input().split())
if N == 1:
    CA = list(map(int, input().split()))
    """
    for i in range(1,N):
        if CA[i] < X:
            print(-1)
            break
    """
    print(CA[0])
else:
    CA = list(map(int, input().split()))
    for i in range(N - 1):
        d = list(map(int, input().split()))
        CA = np.vstack((CA,d))
    C = CA[:,0]
    A = CA[:,1:]

    C_set = []
    for i in range(2 ** (N)):
        book = format(i, '0'+str(N)+'b')
        S = [0] * M
        CC = 0
        for j in range(N):
            if book[j] == "1":
                S = S + A[j,:]
                CC += C[j]
        if min(S) >= X:
            C_set.append(CC)
    if len(C_set) == 0:
        print(-1)
    else:
        print(min(C_set))

Submission status: Wrong Answer

Solution code:
import itertools
N , M , X = (map(int , input().split()))
A = []
for i in range(N):
    A.append(list(map(int , input().split())))
mm = list(itertools.permutations(A))
a = 0
b = 0
count = 0
mx = -1
mx_list = []
for i in mm:
    for m in range(M):
        for j in range(len(i)):
            a += i[j][m+1]
            b += i[j][0]
            if a >= X:
                mx = max(mx , b)
                a = 0
                b = 0
            if j == len(i)-1:
                a = 0
                b = 0
                break
    mx_list.append(mx)
    mx = -1
print(min(mx_list))

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)]
alist=[0]*M
for i in range(N):
    c=int(list[i][0])
    for j in range(1,M+1):
        a=int(list[i][j])
        alist[j-1]+=a
if min(alist)<X:
    print('-1')
else:
    for i in range(N):
        c=int(list[i][0])
        for j in range(1,M+1):
            a=int(list[i][j])

Submission status: Wrong Answer

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

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

lst.sort(key=lambda x: sum(x[1:]) ,reverse=True)

rikaido = [0]*m
rikaido_check1 = [0]*m

rikaido2 = [0]*m
rikaido_check2 = [0]*m

ans1 = 0
ans2 = 0

check1 = 0
for i in lst:
    for j in range(m):
        rikaido[j] += i[j+1]
        if rikaido[j] >= x:
            rikaido_check1[j] = 1
    ans1 += i[0]
    if sum(rikaido_check1) == m:
        check1 = 1
        break

lst.sort(key=lambda x: x[0])

check2 = 0
for i in lst:
    for j in range(m):
        rikaido2[j] += i[j+1]
        if rikaido2[j] >= x:
            rikaido_check2[j] = 1
    ans2 += i[0]
    if sum(rikaido_check2) == m:
        check2 = 1
        break

if check1 == check2 == 0:
    print("-1")
else:
    print(min(ans1,ans2))

Submission status: Wrong Answer

Solution code:

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

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

# 値段の安い順に並び替え
book_list.sort()
print(book_list)

ans = 0

skill_list = [0] * m

for j in range(n) :

    clear = True

    for i in range(m) :
        # print(' i :  {} '.format(i))
        skill_list[i] = skill_list[i] + book_list[j][i]

    for k in range(1, m) :
        # print(' skill_lise[k] :  {} '.format(skill_list[k]))
        if skill_list[k] < x :
            clear = False

    if clear == True :
        ans = skill_list[0]
        break

# まず条件不適を検索
# for j in range(m) :

#     sum = 0

#     print(' j :  {} '.format(j))

#     for i in range(n):

#         print(' i :  {} '.format(i))

#         sum = sum + book_list[i][j + 1]

#     print(' sum :  {} '.format(sum))

#     if sum <= x:
#         ans = -1

print(ans)

Submission status: Wrong Answer

Solution code:
n, m, x = [int(x) for x in input().split()]


def learn(algorithms):
    level = []
    n = len(algorithms[0])
    for i in range(1, n):
        algorithm = [x[i] for x in algorithms]
        level.append(sum(algorithm))
    return level


algorithms = []
for book in range(n):
    algorithm = [int(x) for x in input().split()]
    algorithms.append(algorithm)

algorithms = sorted(algorithms, key=lambda x: x[0])
a = len(algorithms)
money = []
for i in range(a):
    algorithm = algorithms[i][1:]
    if len(list(filter(lambda a: a >= x, algorithm))) == len(algorithm):
        # Best Case
        print(algorithm[0])
        quit()
    else:
        for numberOfBooks in range(2, a+1):
            if (i + numberOfBooks) >= a - 1:
                current = len(algorithms[i: i+numberOfBooks])
                books = algorithms[i: i+numberOfBooks] + \
                    algorithms[:numberOfBooks-current]
            else:
                books = algorithms[i: i+numberOfBooks]

            level = learn(books)
            if len(list(filter(lambda a: a >= x, level))) == len(level):
                money.append(sum([x[0] for x in books]))

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

Submission status: Wrong Answer

Solution code:
n,m,x=map(int, input().split())
c=[0 for i in range(n+1)]
a=[[0 for i in range(m+1)] for j in range(n+1)]
r=[0 for i in range(m+1)]
check=4096
ans=0
lis=[]
def rup(v):
    for k in range(1,m+1):
        r[k]+=a[v][k]

for i in range(1,n+1):
    l = input().split()
    c[i]=int(l[0])
    for j in range(1,m+1):
        a[i][j]=int(l[j])

for i in range(1,m+1):
    for j in range(1,n+1):
        r[i]+=a[j][i]

for i in range(1,m+1):
    if r[i]<x:
        ans=-1

if ans==0:
    for i in range(2**n):
        r=[0 for i in range(m+1)]
        ans=0
        check+=1
        checkbin=list(str(bin(check)))
        for q in range(n):
            if checkbin[12-q]==1:
                for k in range(1,m+1):
                    r[k]+=a[q+1][k]
            for s in range(1,m+1):
                if r[s]<x:
                    ans=-1
            if ans==0:
                pr=0
                for p in range(n):
                    if checkbin[12-k]==1:
                        pr+=c[k+1]
                lis.append(pr)
    print(lis)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import numpy as np

info = input().split(' ')
textbook = int(info[0])
algorithm = int(info[1])
goal = int(info[2])

content = []

for i in range(textbook):
    array = list(map(int, input().strip().split()))
    content.append(array)

np_content = np.array(content)
np_content = np_content[np_content[:,0].argsort(), :]

np_sum = [0] * (algorithm + 1)
np_sum_array = np.array(np_sum)

flag = 0
for j in (np_content):
    np_sum_array = np_sum_array + j
    if(np.all(np_sum_array[1:] >= goal)):
        print(np_sum_array[0])
        flag = 1
        break
    else:
        continue
    
if(flag==0):
    print('-1')

Submission status: Wrong Answer

Solution code:
from itertools import combinations
import numpy as np

N,M,X=map(int, input().split())
list_=[list(map(int, input().split())) for _ in range(N)]
cost=1000001
list_C=[]

for i in range(N):
	list_C=np.array(list(combinations(list_,N-i)))
	count=0
	#print(list_C)
	for h in range(len(list_C)):
		if all(np.sum(list_C[h], axis=0)[1:]>=X):
			if np.sum(list_C[h], axis=0)[0]<cost:
				cost=np.sum(list_C[h], axis=0)[0]
			#print(np.sum(list_C[h], axis=0),cost)
			count+=1
	if count==0:
		break

print(cost if cost<1000001 else "-1")

Submission status: Wrong Answer

Solution code:
import itertools

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

a = [[0] * (m) for i in range(n)]

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

min_score = 100000000
ok_flag = 1

for d in range(0, m+1):
    for v in itertools.permutations(a, d):
        ok_flag = 1
        cost = 0
        for m1 in range(1, d):
            score = 0
            for m2 in range(0, d):
                score += v[m2][m1]

            if score < x:
                ok_flag = 0
            
            if ok_flag == 1:
                for m3 in range(d):
                    cost += v[m3][0]
                if cost < min_score:
                    min_score = cost

if min_score == 100000000:
    print(-1)
else:
    print(min_score)

Submission status: Wrong Answer

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

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

lst.sort(key=lambda x: sum(x[1:]) ,reverse=True)

rikaido = [0]*m
rikaido_check1 = [0]*m

rikaido2 = [0]*m
rikaido_check2 = [0]*m

ans1 = 0
ans2 = 0

check1 = 0
for i in lst:
    for j in range(m):
        rikaido[j] += i[j+1]
        if rikaido[j] >= x:
            rikaido_check1[j] = 1
    ans1 += i[0]
    if sum(rikaido_check1) == m:
        check1 = 1
        break

lst.sort(key=lambda x: x[0])

check2 = 0
for i in lst:
    for j in range(m):
        rikaido2[j] += i[j+1]
        if rikaido2[j] >= x:
            rikaido_check2[j] = 1
    ans2 += i[0]
    if sum(rikaido_check2) == m:
        check2 = 1
        break
print(lst)
if check1 == check2 == 0:
    print("-1")
else:
    print(min(ans1,ans2))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n, m, x = map(int, input().split())
d = []
for i in range(n):
    d.append([int(i) for i in input().split()])
    
def func(i,j,l):
    s = 0
    for m in range(i,j+1):
        s += l[m]
    return s

d.sort(key = lambda x: -1*(func(1,m,x)/x[0]))

u = [0]*m
cost = 0
for i in d:
    for j in range(m):
        u[j] += i[j + 1]
    cost += i[0]
    u.sort()
    if u[0] >= x:
        print(cost)
        break

if u[0] < x:
    print(-1)

Submission status: Wrong Answer

Solution code:
def main():
  n,m,x = map(int,input().split())
  
  books = []
  
  for _ in range(n):
    books.append(list(map(int,input().split())))
  
  result = -1
  for i in range(len(books)):
    result = check(i,books,books[i][:],x,result)
  
  return result

def check(index,books,buys,border,result):
  #print(str(index)+':'+str(buys)+':'+str(result))
  exit = True
  #再起終了判定
  if result == -1 or buys[0] <= result:
    for point in buys[1:]:
      if point < border:
        exit = False
        break
  if exit:
    if result == -1 or result > buys[0]:
      result = buys[0]
      for i in range(len(buys)):
        buys[i] = buys[i] - books[index][i]
      return result
    
  #未クリア時処理
  for i in range(index+1,len(books)):
    for j in range(len(buys)):
      buys[j] = buys[j] + books[i][j]
    result = check(i,books,buys,border,result)
  
  return result
    
print(main())

Submission status: Wrong Answer

Solution code:
n,m,x = map(int, input().split())
c = [list(map(int, input().split())) for i in range(n)]
ex = [0] * m
ans = 0
for i in range(n):
  ans = ans + c[i][0]
  for j in range(m):
    ex[j] = int(ex[j]) + c[i][j+1]
    
flag = 1
for j in range(m):
  if ex[j] < x:
    flag = 0
if flag == 0:
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools

n,m,x=map(int,input().split())
li=[list(map(int,input().split())) for i in range(n)]
li=np.array(li)
y=np.sum(li, axis=0)
if(np.min(y[1:])<x):
    print(-1)

def check(i):
    a=list(itertools.combinations(range(n), i))
    
    ans=(10**5)*n
    for j in a:
        b=[0]*(m+1)
        for s in j:
            b+=li[s]
            
        #print(np.min(b[1:]))
        if(np.min(b[1:])>=x) and ans>b[0]:
            ans=b[0]
    return(ans)

for i in range(1,n+1):
    ans=check(i)
    if(ans>0 and ans!=(10**5)*n):
        print(ans)
        break

Submission status: Wrong Answer

Solution code:
import itertools
n,m,x = map(int, input().split())
book = []
for i in range(n):
  b = list(map(int, input().split()))
  book.append(b)
book = sorted(book, key=lambda x:x[0])
junretu = itertools.permutations(range(n))
min_nedan = 10**9
for j in junretu:
  count_list = [0]*m
  nedan = 0
  for b in j:
    naiyou = book[b]
    nedan += naiyou[0]
    for i in range(1, m+1):
      count_list[i-1] += naiyou[i]
    if min(count_list)>=x:
      print(nedan)
      exit()
  else:
    print(-1)
    exit()
  if nedan < min_nedan:
    min_nedan = nedan
print(min_nedan)

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
i = 1
a = [[0 for i in range(m)] for j in range(n)]
c = [0 for i in range(n)]
while i <= n:
    li = list(map(int,input().split()))
    c[i-1] = li[0]
    a[i-1] = li[1:]
    i+=1

res_all = -1
for k in range(n):
    for l in range(k+1,n,1):
        aa = a[k:l+1]
        understandings = [0 for t in range(m)]
        for j in range(m):
            understanding = 0
            for i in range(l-k+1):
                understanding = understanding + aa[i][j]
            understandings[j] = understanding
        
        if all(elem >= x for elem in understandings):
            res = sum(c[k:l+1])
            if res_all == -1:
                res_all = res
            else:
                if 0 < res < res_all:
                    res_all = res

print(res_all)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
import numpy as np

N,M,X=map(int, input().split())
list_=[list(map(int, input().split())) for _ in range(N)]
cost=1000001
list_C=[]

for i in range(N):
	list_C=np.array(list(combinations(list_,N-i)))
	count=0
	#print(list_C)
	for h in range(len(list_C)):
		if all(np.sum(list_C[h], axis=0)[1:]>=X):
			if np.sum(list_C[h], axis=0)[0]<cost:
				cost=np.sum(list_C[h], axis=0)[0]
			#print(np.sum(list_C[h], axis=0),cost)
			count+=1
	if count==0:
		break

print(cost if cost<1000001 else -1)

Submission status: Wrong Answer

Solution code:
import numpy as np  
N, M, X = map(int, input().split())
a = np.array([input().split() for l in range(N)], dtype=np.int64)
sum = np.sum(a, axis=0)
sum = sum[1:M+1]
if np.min(sum)<X:
  print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np

def yn(t,x):
  for j in range(len(t)-1):
    if t[j+1] < x:
      return False
  return True
  
n,m,x=list(map(int,input().split()))
a=[]
for i in range(n):
  a.append(list(map(int,input().split())))
  
a=np.array(a)
for i in range(m):
  a=a[np.argsort(a[:,i+1])]
a=a[np.argsort(a[:,0])]
t=np.sum(a,axis=0)

for i in range(1,n+1):
  if yn(t-a[-i],x):
    t = t-a[-i]

if not yn(t,x):
  print("-1")
else:
  print(t[0])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N, M, X = map(int, input().split())
    CA = []
    for _ in range(N):
        CA.append([int(i) for i in input().split()])
        CA.sort()
    sums = [X] * M
    suns2 = [X] * M
    cost1 = 0
    cost2 = 0
    for ca in CA:
        cost1 += ca[0]
        cost2 += ca[0]
        for i in range(M):
            sums[i] -= ca[i + 1]
            suns2[i] -= ca[i + 1]
    for i in range(len(sums)):
        if sums[i] > 0:
            print(-1)
            exit()

    for ca in reversed(CA):
        tmp = []
        for i in range(M):
            tmp.append(ca[i + 1] + sums[i])
            if tmp[i] > 0:
                break
            if i == M - 1:        # 最後まで来たra
                cost1 -= ca[0]
                sums = [i for i in tmp]

    for ca in CA:
        tmp = []
        for i in range(M):
            tmp.append(ca[i + 1] + suns2[i])
            if tmp[i] > 0:
                break
            if i == M - 1:        # 最後まで来たra
                cost2 -= ca[0]
                suns2 = [i for i in tmp]
    print(min(cost1, cost2))    

    pass

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, M, X = map(int,input().split())
a=[]
b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
c=[]
for i in range(N):
    a.append(input().split())
    c.append(0)

check=0
ans=-1
for i in range(2**N):
    b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    for j in range(N):
        if 0x01 & (i >> j):
            for n in range(M+1):
                b[n] = b[n] + int(a[j][n])

        check=0
        print(b)
        for k in range(1,M):
            if b[k] < X:
                check=1

        if check==0:
            if ans == -1 or ans > b[0]:
                ans = b[0]

print(ans)

Submission status: Wrong Answer

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

ans   = 10**30
cost  = 0
score = [0]*m

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

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

Submission status: Wrong Answer

Solution code:
#C
import numpy as np
flg = True
n,m,x = map(int,input().split())
algo = []
tmp = []
for _ in range(n):
    algo.append(list(map(int,input().split())))
    

algo_n = np.array(algo)
algo_sum = algo_n.sum(axis=0)
gokei = algo_sum.tolist()
money = gokei[0]
gokei = gokei[1:]

#チェックする
for i in range(m):
    if gokei[i] < x:
        flg = False
        print(-1)
        break

algo.sort(key= lambda x:x[0],reverse=True)

#print(algo)
#print(gokei)
# 計算用の関数
def hikizan(lst1,lst2):
#lst1 - lst2
    lst_ans = [0 for _ in range(len(lst1))]
    for i in range(len(lst1)):

        l1 = lst1[i]
        l2 = lst2[i]
        l1 -= l2
        lst_ans[i] = l1
    return lst_ans

def check_lst(lst1,target):
    for i in range(len(lst1)):
        if lst1[i] < target:
            return False
        
    return True

if flg:
    for k in range(n):
        gokei_t = gokei[:]
        money_t = money
        for i in range(k,n):
            if check_lst(hikizan(gokei_t,algo[i][1:]),x):
                gokei_t = hikizan(gokei_t,algo[i][1:])
                money_t -= algo[i][0]
                tmp.append(money_t)
            
        tmp.append(money_t)    
 

    print(min(tmp))

Submission status: Wrong Answer

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

b = [i for i in range(N)]
n = len(b)

b_pairs = []
for i in range(1, n+1):
    b_pairs += list(itertools.combinations(b, i))

cnt = 0
A = [0] * M
B = []
C = []
for i in range(2 ** N - 1):
  w = len(b_pairs[i])
  for j in range(M):
    for k in range(w):
      A[j] += l[b_pairs[i][k]][j + 1]
  B.append(A)
  A = [0] * M
  
for i in range(2 ** N - 1):
  w = len(b_pairs[i])
  for k in range(w):
    cnt += l[b_pairs[i][k]][0]
  C.append(cnt)
  cnt = 0

for i in range(len(B)):
  for j in range(M):
    if B[i][j] >= X:
      pass
    else:
      B[i] = 0
      break
    
for i in range(len(B)):
  if B[i] != 0:
    B[i] = C[i]
  else:
    B[i] = 1000000000000

print(min(B))

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
b = [sum([i/j[0] for i in j[1:]]) for k,j in enumerate(a)]
c = sorted(b,reverse=True)
l = [0]*m
p = 0
for i in c:
    if all([i>=x for i in l]):
        break
    f = a[b.index(i)]
    p+=f[0]
    for k,j in enumerate(f[1:]):
        l[k]+=j
if all([i>=x for i in l]):
    print(p)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import itertools
import sys

n, m, x = map(int, input().split())
num = list(list(map(int, input().split())) for i in range(n))

s = [i for i in range(n)]
t = []
list_num = []

for i in range(m):
  t.append(list(map(list, itertools.combinations(s, i + 1))))

for i in t:
  for j in i:
    k = [0] * (m + 1)
    for z in j:
      k = tuple(x + y for (x,y) in zip(k, num[z]))
    list_num.append(k)


list_num = list(sorted(list_num, key =lambda w : w[0]))
q = []

flag2 = 0

for i in list_num:
  flag = 1
  for j in range(1, m + 1):
    if(i[j] < x):
      flag = 0
  if(flag == 1):
    q.append(i[0])
    flag2 = 1

if(flag2 == 1):
  print(min(q))
else: 
  print(-1)

Submission status: Wrong Answer

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

b = [i for i in range(N)]
n = len(b)

b_pairs = []
for i in range(1, n+1):
    b_pairs += list(itertools.combinations(b, i))

cnt = 0
A = [0] * M
B = []
C = []
for i in range(2 ** N - 1):
  w = len(b_pairs[i])
  for j in range(M):
    for k in range(w):
      A[j] += l[b_pairs[i][k]][j + 1]
  B.append(A)
  A = [0] * M
  
for i in range(2 ** N - 1):
  w = len(b_pairs[i])
  for k in range(w):
    cnt += l[b_pairs[i][k]][0]
  C.append(cnt)
  cnt = 0

for i in range(len(B)):
  for j in range(M):
    if B[i][j] >= X:
      pass
    else:
      B[i] = 0
      break
    
for i in range(len(B)):
  if B[i] != 0:
    B[i] = C[i]
  else:
    B[i] = 100000000

print(min(B))

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np

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

  arr = []
  for i in range(N):
    I = list(map(int, input().split()))
    arr.append(I)

  arr1 = arr
  arr = np.asarray(arr)

  S = np.sum(arr, axis=0)

  flag = True

  for i in range(1,M):
    if S[i] < X:
      flag = False
    else:
      pass

  if(flag==False):
    print(-1)
    exit()
  else:
    pass

  min_price = 10**9 

  for i in range(1,N+1):
    p = itertools.permutations(arr1, i)
    for j in p:
      arr2 = []
      for k in range(len(j)):
        arr2.append(j[k])
      arr2 = np.asarray(arr2)
      S2 = np.sum(arr2, axis=0)
      flag = True
      for i in range(1,M):
        if S2[i] < X:
          flag = False
      if(flag):
        if min_price > S2[0]:
          min_price = S2[0]

  print(min_price)



if __name__ == "__main__":
  main()

Submission status: Wrong Answer

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

ans   = 10**30
cost  = 0
score = [0]*m

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

if ans==10**30:
  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 i in range(n)]
b = [sum([i/j[0] for i in j[1:]]) for k,j in enumerate(a)]
c = sorted(b,reverse=True)
l = [0]*m
p = 0
for i in c:
    if all([i>=x for i in l]):
        break
    f = a[b.index(i)]
    print(f,i)
    p+=f[0]
    for k,j in enumerate(f[1:]):
        l[k]+=j
if all([i>=x for i in l]):
    print(p)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np

N, M, X = map(int, input().split())
C_A_list = []
for i in range(N):
    C_A_list.append(np.array(list(map(int, input().split()))))

# print(N, M, X)
# print(C_A_list)

# N, M, X = 3, 3, 10
# C_A_list = [np.array([60, 2, 2, 4]),
#             np.array([70, 8, 7, 9]),
#             np.array([50, 2, 3, 9])]

price_min = -1
for i in range(1, M + 1):
    for j in itertools.combinations(C_A_list, i):
        # print(j)
        sum_list = sum(j)
        # print(sum_list[1:])
        if min(sum_list[1:]) >= X:
            if price_min >= 0:
                prince_min = min(price_min, sum_list[0])
            else:
                price_min = sum_list[0]

print(price_min)

Submission status: Wrong Answer

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

###
# main
if(__name__ == '__main__'):
    # input
    n, m, x = map(int, input().split(" "))

    book = []
    c_sum = 0
    sum_li = [0 for _ in range(m)]
    cp_dict = [{} for _ in range(m)]
    for i in range(n):
        b = list(map(int, input().split(" ")))
        book.append(b)
        c = b[0]
        c_sum += c
        for al in range(m):
            a = b[al+1]
            cp = a/c
            cp_dict[al][cp] = c
            sum_li[al] += a

    ans = -1
    for al in range(m):
        if sum_li[al] < x:
            break
    else:
        ans = c_sum

    print(ans)

# else:
    # do nothing

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np

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

result = []
adds = []
for j in range(1,n+1):
     for conb in itertools.combinations(san, j):
        result.append(list(conb)) #タプルをリスト型に変換

for i in result:
    t = np.zeros([m+1], dtype=int)
    for j in i:
        t = t + np.array(j)

    adds.append(t)

price = -1
ans = 0
for num, i in enumerate(adds):
    use = True
    for j in range(1,m+1):
        if i[j] < 10:
            # print(i)
            use = False
            break

    if use:
        # print(i)
        # print(result[num])
        if price == -1 or price > i[0]:
        # if price > i[0]:
            price = i[0]
            ans = num

print(price)