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: Runtime Error

Solution code:
import numpy as np

i = list(map(int, input().split()))
N = i[0]
M = i[1]
X = i[2]

a = []

for _ in range(N):
    tmp = list(map(int, input().split()))
    a.append(tmp)

a_num = np.array(a)

k = 0
b = '0' + str(N) + 'b'
bit_l= []
for i in range (2 ** N):
    tmp = format(k, b)
    for j in range(N):
        bit.append(int(tmp[j]))
    
    bit_l.append(bit)
    bit = []
    k += 1



understand = [0]*M
understand_n = np.array(understand)


price = 0
price_min = 1000000

for i in range(2 ** N):
    for j in range(N):
        if(bit_l[i][j] == 1):
            #print("i,j = ",i,j)
            #print("a_num = ",a_num[j,1:])
            understand_n += a_num[j][1:]
            #print('理解度 ',understand_n)
            price += a_num[j][0]
            #print('price ',price )
            
    #print('==============')
    if (understand_n.min() >= X) and (price < price_min):
        #print('^^^^^^^^^^^^^^')
        #print("ifのなかの理解度",understand_n)
        price_min = price
        #print("price_min ",price_min)
        #print('^^^^^^^^^^^^^^^')
    price =0
    understand_n = [0]*M
    
if price_min == 1000000:
    print(-1)
else:
    print(price_min)

Submission status: Runtime Error

Solution code:
n,m,x = map(int, input().split())
import numpy as np
b = []
c = []
for i in range(n):
  tmp = list(map(int, input().split()))
  b.append(tmp)
skill = np.array([0 for i in range(m)])
b = np.array(b)
ind = 0
rms = []
cos = 0
ma = float('inf')
flg = False
for i in range(2**n):
  bins = bin(i)[2:]
  if len(bins) < m:
    bins = bins + "0"*int(m-len(bins))
  bins = np.array(list(map(int,bins)))
  res = (b.transpose() * bins).transpose().sum(axis=0)
  if all(res[1:] > x) and res[0] < ma:
    ma = res[0]
    flg = True
if flg:
  print(ma)
else:
  print("-1")

Submission status: Runtime Error

Solution code:

i = list(map(int, input().split()))
N = i[0]
M = i[1]
X = i[2]

a = []

for _ in range(N):
    tmp = list(map(int, input().split()))
    a.append(tmp)

a_num = np.array(a)

k = 0
b = '0' + str(N) + 'b'
bit_l= []
for i in range (2 ** N):
    tmp = format(k, b)
    for j in range(N):
        bit.append(int(tmp[j]))
    
    bit_l.append(bit)
    bit = []
    k += 1



understand = [0]*M
understand_n = np.array(understand)


price = 0
price_min = 9999999999

for i in range(2 ** N):
    for j in range(N):
        if(bit_l[i][j] == 1):
            #print("i,j = ",i,j)
            #print("a_num = ",a_num[j,1:])
            understand_n += a_num[j][1:]
            #print('理解度 ',understand_n)
            price += a_num[j][0]
            #print('price ',price )
            
    #print('==============')
    if (understand_n.min() >= X) and (price < price_min):
        #print('^^^^^^^^^^^^^^')
        #print("ifのなかの理解度",understand_n)
        price_min = price
        #print("price_min ",price_min)
        #print('^^^^^^^^^^^^^^^')
    price =0
    understand_n = [0]*M
    
if price_min == 9999999999:
    print(-1)
else:
    print(price_min)

Submission status: Runtime Error

Solution code:
import numpy as np

i = list(map(int, input().split()))
N = i[0]
M = i[1]
X = i[2]

a = []

for _ in range(N):
    tmp = list(map(int, input().split()))
    a.append(tmp)

a_num = np.array(a)

k = 0
b = '0' + str(N) + 'b'
bit_l= []
for i in range (2 ** N):
    tmp = format(k, b)
    for j in range(N):
        bit.append(int(tmp[j]))
    
    bit_l.append(bit)
    bit = []
    k += 1



understand = [0]*M
understand_n = np.array(understand)


price = 0
price_min = 9999999999

for i in range(2 ** N):
    for j in range(N):
        if(bit_l[i][j] == 1):
            #print("i,j = ",i,j)
            #print("a_num = ",a_num[j,1:])
            understand_n += a_num[j][1:]
            #print('理解度 ',understand_n)
            price += a_num[j][0]
            #print('price ',price )
            
    #print('==============')
    if (understand_n.min() >= X) and (price < price_min):
        #print('^^^^^^^^^^^^^^')
        #print("ifのなかの理解度",understand_n)
        price_min = price
        #print("price_min ",price_min)
        #print('^^^^^^^^^^^^^^^')
    price =0
    understand_n = [0]*M
    
if price_min == 9999999999:
    print(-1)
else:
    print(price_min)

Submission status: Runtime Error

Solution code:
import numpy as np

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

NEW = 0

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

def check(num):
  return num>=X

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

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

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

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

Submission status: Runtime Error

Solution code:
import numpy as np

i = list(map(int, input().split()))
N = i[0]
M = i[1]
X = i[2]

a = []

for _ in range(N):
    tmp = list(map(int, input().split()))
    a.append(tmp)
    
a_num = np.array(a)

k = 0
b = '0' + str(N) + 'b'
bit_l= []
for i in range (2 ** N):
    tmp = format(k, b)
    for j in range(N):
        bit.append(int(tmp[j]))
    
    bit_l.append(bit)
    bit = []
    k += 1
    
understand = [0]*M
understand_n = np.array(understand)


price = 0
price_min = 9999999999

for i in range(2 ** N):
    for j in range(N):
        if(bit_l[i][j] == 1):
            #print("i,j = ",i,j)
            #print("a_num = ",a_num[j,1:])
            understand_n += a_num[j][1:]
            #print('理解度 ',understand_n)
            price += a_num[j][0]
            #print('price ',price )
            
    #print('==============')
    if (understand_n.min() >= X) and (price < price_min):
        #print('^^^^^^^^^^^^^^')
        #print("ifのなかの理解度",understand_n)
        price_min = price
        #print("price_min ",price_min)
        #print('^^^^^^^^^^^^^^^')
    price =0
    understand_n = [0]*M
    
if price_min == 9999999999:
    print(-1)
else:
    print(price_min)

Submission status: Runtime Error

Solution code:
big_int = 10 ** 9

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

L = []
for i in range(N):
  L.insert( tuple(map(int, input().split())) )

def foo(i):
  T = [0 for j in range(M+1)]
  for j in range(N):
    for k in range(M+1):
      T[k] += L[j][k] * (i%2)
      i //= 2
  for k in range(1,M+1):
    if T[k] < X:
      return big_int
  return T[0]
  
ans = big_int

for i in range(2**N):
  ans = min(ans, foo(i))
  
if ans == big_int:
  print(-1)
else:
  print(ans)

Submission status: Runtime Error

Solution code:
n,m,x = map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(n)]
c = [ca[i][0] for i in range(n)]
a = [ca[i][1:] for i in range(n)]
l = 0
ans = sum(c) 
for i in range(2 ** n):
    get = [0] * m
    kari = 03 
    for j in range(n):
        if (i >> j) & 1: #i(ex.5)を2進数(ex.101)に一桁ずつ変換
            get = [x + y for (x, y) in zip(get, a[j])]
            kari += c[j]
    #print(get,kari)
    #print([k >= x for k in get])
    if all([k >= x for k in get]):
        ans = min(ans,kari)
        l += 1
if l == 0:
    ans = -1
    
print(ans)

Submission status: Runtime Error

Solution code:
n,m,x = map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(n)]
c = [ca[i][0] for i in range(n)]
a = [ca[i][1:] for i in range(n)]
l = 0
for i in range(2 ** n):
    ans = sum(c)
    get = [0] * m
    kari = 0
    for j in range(n):
        if (i >> j) & 1:　#i(ex.5)を2進数(ex.101)に一桁ずつ変換
            get = [x + y for (x, y) in zip(get, a[j])]
            kari += c[j]
    if all([z >= x for z in get]):
        ans = min(ans,kari)
        l += 1
if l == 0:
    ans = -1

print(ans)

Submission status: Runtime Error

Solution code:
n,m,x=map(int,input().split())
arr=[[0 for i in range(m+1)] for j in range(n)]
b=[0]*18

flag=1
for i in range(n):
    arr[i]=list(map(int,input().split()))
for i in range(2**n):
    b=[0]*18
    for j in range(n):
        flag=1
        if (1& i>>j):
            for s in range(m+1):
                b[s]= b[s]+arr[j][s]
        for y in range(1,m+1):
            if(b[y]<x):
                flag=0
                
        if flag :
            if ans==-1 or ans>b[0]:
                ans=b[0]
print(ans)

Submission status: Runtime Error

Solution code:
#ABC167-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())))
    
book = list(itertools.product([0,1],repeat=n))
abi = [0 for _ in range(m)]

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

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

Submission status: Runtime Error

Solution code:
import sys
import os
import math
import bisect
import collections
import itertools
import heapq

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M, X = il()
    CA = [il() for _ in range(N)]

    ret = MAX
    for n in range(1 << N):
        k = 0
        A = [0] * M
        for m in range(M):
            c, *a = CA[m]

            if n >> m & 1:
                k += c
                for i in range(len(a)):
                    A[i] += a[i]

                if all([aa >= X for aa in A]):
                    break
        else:
            continue

        ret = min(ret, k)

    print(-1 if ret == MAX else ret)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
import os
import math
import bisect
import collections
import itertools
import heapq

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M, X = il()
    CA = [il() for _ in range(N)]

    ret = MAX
    for n in range(1 << N):
        k = 0
        A = [0] * M
        for m in range(M):
            c, *a = CA[m]

            if n >> m & 1:
                k += c
                for i in range(len(a)):
                    A[i] += a[i]

                if all([aa >= X for aa in A]):
                    break
        else:
            continue

        ret = min(ret, k)

    print(ret)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N,M,X=map(int,input().split())
C=[]
A=[[] for  _  in range(N)]
for i in range(N):
  tmpA=list(map(int,input().split()))
  C+=[tmpA[0]]
  A[i]=tmpA[1:]

costmin=float('inf')
for k in range(2**N):
  tansaku=k
  koubai=[0 for i in range(N)]
  rikaido=[0 for i in range(N)]
  cost=0
  for i in range(N-1):
    koubai[i]=tansaku//(2**(N-i-1))
    tansaku=tansaku%(2**(N-i-1))
  koubai[-1]=tansaku
  for i in range(N):
    if koubai[i]==1:
      cost+=C[i]
      for j in range(M):
        rikaido[j]+=A[i][j]
  for i in range(M):
    if rikaido[i]<X:
      break
  else:
    costmin=min(costmin,cost)
if costmin!=float('inf'):
  print(costmin)
else:
  print(-1)

Submission status: Runtime Error

Solution code:
N,M,X=map(int,input().split())
C=[]
A=[[] for  _  in range(N)]
for i in range(N):
  tmpA=list(map(int,input().split()))
  C+=[tmpA[0]]
  A[i]=tmpA[1:]
tf=1
for i in range(M):
  s=0
  for j in range(N):
    s+=A[j][i]
  if s<X:
    tf=0
    break
if tf==0:
  print(-1)
else:
  costmin=float('inf')
  for k in range(2**N):
    tansaku=k
    koubai=[0 for i in range(N)]
    rikaido=[0 for i in range(N)]
    cost=0
    for i in range(N-1):
      koubai[i]=tansaku//(2**(N-i-1))
      tansaku=tansaku%(2**(N-i-1))
    koubai[-1]=tansaku
    for i in range(N):
      if koubai[i]==1:
        cost+=C[i]
        for j in range(M):
          rikaido[j]+=A[i][j]
    for i in range(M):
      if rikaido[i]<X:
        break
    else:
      costmin=min(costmin,cost)

Submission status: Runtime Error

Solution code:
from itertools import product

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

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

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

Submission status: Runtime Error

Solution code:

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

import numpy as np

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

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

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

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

dp=[10**10]

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

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

Submission status: Runtime Error

Solution code:

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

import numpy as np

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

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

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

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

dp=[10**10]

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


print(int(dp))

Submission status: Runtime Error

Solution code:
import itertools

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

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

saisyo = float("inf")
for i in intertools.product(range(2), N):
    a = [0]*M
    gokei = 0
    for j in range(N):
        if i[j] == 1:
            gokei += A[j][0]
            for k in range(1, M+1):
                a[k-1] += A[j][k]
    if min(a) >= X:
        saisyo = min(saisyo, gokei)

print(saisyo if saisyo != float("inf") else -1)

Submission status: Runtime Error

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

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

    min_total_cost = 10**9

    for i in range(2**N):
        total_cost = 0
        learned = [0] * M

        for j in range(N):
            if (i >> j) & 1:
                cost, points = books[j]
                total_cost += cost
                
                learned = [x + y for x, y in zip(learned, points)]

        if min(learned) >= X:
            min_total_cost = min(min_total_cost, total_cost)

    if min_total_cost == 10**9:
        print('-1')
    else:
        print(min_total_cost)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import numpy as np


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

    books = np.array([list(map(int, input().split())) for _ in range(N)])

    min_total_cost = 10**9

    for i in range(2**N):
        to_read_indexes = np.array(list(str(i)), dtype=int)
        to_read_books = books[to_read_indexes, :]
        total_cost = to_read_books[:, 0].sum()
        increased_levels = to_read_books[:, 1:].sum(axis=0)

        if min(increased_levels) >= X:
            min_total_cost = min(min_total_cost, total_cost)

    if min_total_cost == 10**9:
        print('-1')
    else:
        print(min_total_cost)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m,x=map(int,input().split())
C=[]
for i in range(n):
    a=list(map(int,input().split()))
    C.append(a)
pattern=[]
toBuy=[]
for i in range(2**n):
    toBuy=[]
    for j in range(n):
        if ((i>>j)&1):
            toBuy.append(C[j])
 #   print(toBuy)
    pattern.append(toBuy)
#print(pattern)
X=[0]*m #mつのアルゴリズムそれぞれの経験値
xsum=0#とりあえずはじくためのやつ
sum=0#値段
min=12000000 
for tb in pattern:#toBuyについて
    sum=0
    xsum=0
    X=[0]*m
    for c in tb:
        for j in range(len(c)):
            if j==0:
                sum+=c[j]#price
            else:
                xsum+=c[j]#経験値そうごう
                X[j-1]+=c[j]#経験値各自
    if xsum<x*m:
        continue
    else:
        for eX in X:
            if eX<x:
                check=1
        if check==1:
            check=0
            continue
        if sum<min:
            min=sum
if min==12000000:
    print(-1)
else:
    print(min)

Submission status: Runtime Error

Solution code:
import sys
import math

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

#縦->横の順
#print(c_list[2][1])
ans_list = []
for h in range(1, m):
    ans = 0
    flg = 1
    for j in range(n):
        ans += c_list[j][h]
        if ans >= x:
            ans_list.append(c_list[j][0])
            flg = 0
            continue
    if flg == 1:
        print(-1)
        sys.exit()
        
if flg == 0:
    print(sum(set(ans_list)))
else:
    print(-1) 
#print(sum(c_list[i][0], c_list[j][0]))

Submission status: Runtime Error

Solution code:
n,m,x=map(int,input().split())
C=[]
for i in range(n):
    a=list(map(int,input().split()))
    C.append(a)
pattern=[]
toBuy=[]
for i in range(2**n):
    toBuy=[]
    for j in range(n):
        if ((i>>j)&1):
            toBuy.append(C[j])
 #   print(toBuy)
    pattern.append(toBuy)
#print(pattern)
X=[0]*m #mつのアルゴリズムそれぞれの経験値
xsum=0#とりあえずはじくためのやつ
sum=0#値段
min=12000000 
for tb in pattern:#toBuyについて
    sum=0
    xsum=0
    X=[0]*m
    for c in tb:
        for j in range(len(c)):
            if j==0:
                sum+=c[j]#price
            else:
                xsum+=c[j]#経験値そうごう
                X[j-1]+=c[j]#経験値各自
    if xsum<x*m:
        continue
    else:
        for eX in X:
            if eX<x:
                check=1
        if check==1:
            check=0
            continue
        if sum<min:
            min=sum
if min==12000000:
    print(-1)
else:
    print(min)

Submission status: Runtime Error

Solution code:
from itertools import product

N, M, X = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
ans = float("inf")

for now in product(range(2), N):
    res = 0
    An = [0 for _ in range(M)]
    for n in range(N):
        if now[n] == 1:
            res += A[n][0]
            An = [An[j] + A[n][j+1] for j in range(M)]
    if min(An) >= X:
        ans = min(ans, res)

if ans == float("inf"):
    print(-1)
else:
    print(ans)

Submission status: Runtime Error

Solution code:
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)


def main():
    N, M, X = map(int, input().split())
    CA_list = [list(map(int,list(input().split(" ")))) for i in range(M)]
    Ci_sum_list = []
    
    for i in range(2 ** N):
        sum_list = [0 for i in range(M + 1)]
        for j in range(N):
            if ((i >> j) & 1):
                sum_list = [x + y for (x, y) in  zip(sum_list, CA_list[j])]
                
        logging.info(sum_list)
        if [x for x in sum_list[1:] if x < X]:
            continue
        else:
            Ci_sum_list.append(sum_list[0])

    if Ci_sum_list:
        print(min(Ci_sum_list))
    else:
        print(-1)
        
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from itertools import product as pr
n,m,x=[int(i) for i in input().split()]
l=[[int(i) for i in input().split()]for j in range(n)]
p=list(pr([0,1],repeat=n))
suml=[[sum([l[j][k]*i[j] for j in range(n)])for k in range(m+1)]for i in p]
ans=[i[0] for i in suml if all([i[j] >=x for j in range(1,n+1)])]
if len(ans)==0:
  print(-1)
else:
  print(min(ans))

Submission status: Runtime Error

Solution code:
from itertools import product as pr
n,m,x=[int(i) for i in input().split()]
l=[[int(i) for i in input().split()]for j in range(n)]
p=list(pr([0,1],repeat=n))
suml=[[sum([l[j][k]*i[j] for j in range(n)])for k in range(m+1)]for i in p]
ans=min([i[0] for i in suml if all([i[j] >=x for j in range(1,6)])])
print(ans)

Submission status: Runtime Error

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[n-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: Runtime Error

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

import numpy as np

A=[]
B=[]

for i in range(N):
  A.append(list(map(int,input().split())))

#for i in range(M):
#  B.append([A[j][i] for j in range(N)])

C=[]
temp=[0 for i in range(N)]

for i in range(2**N):
  for j in range(N):
    if (i >> j) & 1:
      temp[j]=1
    else:
      temp[j]=0
  tempE=[0 for i in range(M+1)]
  for k in range(N):
    x = np.array(tempE)
    y = np.array([A[k][j]*temp[k] for j in range(M+1)])
    tempE=x+y
  C.append(tempE)


tempC=float('inf')
for i in range(2**N):
  tempD=min(C[i][1:M+1])
  if tempD>=X:
    tempC=min([tempC,C[i][0]])

if tempC==float('inf'):
  tempC=-1

print(tempC)

Submission status: Runtime Error

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

b=[]
for s in range(2**n):
    a=[1 if s >> i &1 else 0 for i in range(n)] 
    b.append(a)
c=-1
for s in range(2**n):
    f=b[s]
    learn_rate=[0 for i in range(n)]
    cost=0
    for i in range(n):
        if f[i]==1:
            for h in range(m):      
#                 print(lis[i][1][h])
                learn_rate[h]+=lis[i][1][h]
            cost+=lis[i][0]
    flg=1
    for i in range(m):
        if learn_rate[i]<x:
            flg=0
    if flg==1:
        if c==-1:
            c=cost
        else:   
            c=min(c,cost)
print(c)

Submission status: Runtime Error

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

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
for i in range(2,n+1):
    c = list(itertools.combinations(l_, i))
    for j in c:
        # print(j)
        res_ = []
        flag2 = True
        for l in range(3):
            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: Runtime Error

Solution code:
import numpy as np
from itertools import combinations_with_replacement

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

OK = True
CA = np.array(CA)
sums = np.sum(CA,axis=0)
for i in range(1,M+1):
  if sums[i] < X:
    OK = False
    break

if OK == False:
  print(-1)
else:
  As = []
  for A in combinations_with_replacement(range(0, N),N):
    As.append(tuple(set(A)))
  print(As)
  As = list(map(list, set(As)))
  min_ = sums[0]
  for i in hoge:
    mini_CA = []
    for j in i:
      mini_CA.append(CA[j])
    mini_CA = np.array(mini_CA)
    OK2 = True
    sums = np.sum(mini_CA,axis=0)
    for k in range(1,M+1):
      if sums[k] < X:
        OK2 = False
        break
    if OK2 == True and sums[0] < min_:
      min_ = sums[0]
  print(min_)

Submission status: Runtime Error

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

b=[]
for s in range(2**n):
    a=[1 if s >> i &1 else 0 for i in range(n)] 
    b.append(a)
c=-1
for s in range(2**n):
    f=b[s]
    learn_rate=[0 for i in range(n)]
    cost=0
    for i in range(n):
        if f[i]==1:
            for h in range(m):      
#                 print(lis[i][1][h])
                learn_rate[h]+=lis[i][1][h]
            cost+=lis[i][0]
    flg=1
    for i in range(m):
        if learn_rate[i]<x:
            flg=0
    if flg==1:
        if c==-1:
            c=cost
        else:   
            c=min(c,cost)
print(c)

Submission status: Runtime Error

Solution code:
import numpy as np
from itertools import combinations_with_replacement

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

OK = True
CA = np.array(CA)
sums = np.sum(CA,axis=0)
for i in range(1,M+1):
  if sums[i] < X:
    OK = False
    break

if OK == False:
  print(-1)
else:
  As = []
  for A in combinations_with_replacement(range(0, N),N):
    As.append(tuple(set(A)))
  As = list(map(list, set(As)))
  min_ = sums[0]
  for i in hoge:
    mini_CA = []
    for j in i:
      mini_CA.append(CA[j-1])
    mini_CA = np.array(mini_CA)
    OK2 = True
    sums = np.sum(mini_CA,axis=0)
    for k in range(1,M+1):
      if sums[k] < X:
        OK2 = False
        break
    if OK2 == True and sums[0] < min_:
      min_ = sums[0]
  print(min_)

Submission status: Runtime Error

Solution code:
import numpy as np
from itertools import combinations_with_replacement

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

OK = True
CA = np.array(CA)
sums = np.sum(CA,axis=0)
for i in range(1,M+1):
  if sums[i] < X:
    OK = False
    break

if OK == False:
  print(-1)
else:
  # As = []
  # for A in combinations_with_replacement(range(0, N), r=M):
  #   As.append(tuple(set(A)))
  # As = list(map(list, set(As)))
  min_ = sums[0]
  hoge = []
  kouho = list(range(1,N+1))
  for i in itertools.combinations_with_replacement(kouho, N):
    hoge.append(list(set(i)))
  hoge = list(map(list, set(map(tuple, hoge))))
  for i in hoge:
    mini_CA = []
    for j in i:
      mini_CA.append(CA[j])
    mini_CA = np.array(mini_CA)
    OK2 = True
    sums = np.sum(mini_CA,axis=0)
    for k in range(1,M+1):
      if sums[k] < X:
        OK2 = False
        break
    if OK2 == True and sums[0] < min_:
      min_ = sums[0]
  print(min_)

Submission status: Runtime Error

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


for s in range(1,2**n):
    b=[1 if s >> i &1 else 0 for i in range(n)]
c=-1
for s in range(2**n):
    list_01=b[s]
    learn_rate=[0 for i in range(n)]
    cost=0
    for i in range(n):
        f=list_01[i]
        f=int(f)
        if f==1:
            for h in range(m):      
#                 print(lis[i][1][h])
                learn_rate[h]+=lis[i][1][h]
            cost+=lis[i][0]
    flg=1
    for i in range(m):
        if learn_rate[i]<x:
            flg=0
    if flg==1:
        if c==-1:
            c=cost
        else:   
            c=min(c,cost)
print(c)

Submission status: Runtime Error

Solution code:
コードテストの実行待ちです。 自動で更新されますのでリロードせずお待ち下さい。