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:
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(m):
            res = 0
            sum_money = 0
            for k in range(len(j)):
                res += c_[j[k]][l+1]
                sum_money += c_[j[k]][0]
            # print(res,sum_money)
            if res < x:
                flag2 = False
        if flag2:
            resList.append(sum_money)
            flag = True
# print(resList)
print(min(resList) if flag else -1)

Submission status: Wrong Answer

Solution code:

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

A=[0]*n
c=[0]*n

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

for i in range(n):
    c[i]= A[i][0]
    A[i] = A[i][1:]

import numpy as np
import sys

a = np.array(A)

ans = 10**5+1

for s in range(1<<n):
    cost = 0
    d = np.array([0]*m)
    for i in range(n):
        if s>>i&1:
            cost += c[i]
            d += a[i]
    if all(d >= x):
        ans = min(ans,cost)

print(ans if ans != 10**5+1 else '-1')

Submission status: Wrong Answer

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

def getTotal(list):
    return([sum([bookPropertyList[j][i] for j in list]) for i in range(M+1)])

def getIndex(str,query):
    result = []
    for i in range(len(str)):
        if str[i] == query:
            result.append(i)
    return(result)

# bookPropertyListは[価格,M個のアルゴリズムの理解度向上値]をN冊の本についてまとめたリスト
bookPropertyList = [list(map(int,input().split())) for i in range(N)]

# 全部買ってクリアできるか判定
all = [i for i in range(N)]
max = getTotal(all)
result = max[0]
for i in range(M):
    if max[i+1] < X:
        result = -1
        print(-1)
        break

if result != -1:
    for i in range(2**N):
        buyList = getIndex("0"*(N-len(bin(i)[2:]))+bin(i)[2:],"1")
        total = getTotal(buyList)

        # クリア変数の定義
        clear = True

        for i in range(M):
            if total[i] < X:
                clear = False
                break
        if clear and total[0] < result:
            result = total[0]
    print(result)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import itertools

n, m, x = [int(x) for x in stdin.readline().rstrip().split()]
c = [[int(y) for y in x.rstrip().split()] for x in stdin.readlines()]
c.sort()
mi = -1
r = 0

for j in range(1, m + 1):
    li = [x[j] for x in c]
    li.sort(reverse=True)
    for i in range(len(li)):
        if sum(li[:i]) >= x:
            r = max(r, i)
            break

for h in range(r,n):
    for i in itertools.combinations(c, h):
        cnt = [0] * m
        mon = 0
        for j in i:
            cnt = [cnt[k]+j[k+1] for k in range(len(cnt))]
            mon += j[0]
            if sum(1 for k in cnt if k >= x) == m:
                if mi > mon or mi == -1:

                    mi = mon
                break

print(mi)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import itertools

n, m, x = [int(x) for x in stdin.readline().rstrip().split()]
c = [[int(y) for y in x.rstrip().split()] for x in stdin.readlines()]
c.sort()
mi = -1
r = 0

for j in range(1, m + 1):
    li = [x[j] for x in c]
    li.sort(reverse=True)
    for i in range(len(li)):
        if sum(li[:i]) >= x:
            r = max(r, i)
            break

for h in range(r,n):
    for i in itertools.combinations(c, h):
        cnt = [0] * m
        mon = 0
        for j in i:
            cnt = [cnt[k]+j[k+1] for k in range(len(cnt))]
            mon += j[0]
            print(cnt)            
            if sum(1 for k in cnt if k >= x) == m:
                if mi > mon or mi == -1:

                    mi = mon
                break

print(mi)

Submission status: Wrong Answer

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

def getTotal(list):
    return([sum([bookPropertyList[j][i] for j in list]) for i in range(M+1)])

def getIndex(str,query):
    result = []
    for i in range(len(str)):
        if str[i] == query:
            result.append(i)
    return(result)

# bookPropertyListは[価格,M個のアルゴリズムの理解度向上値]をN冊の本についてまとめたリスト
bookPropertyList = [list(map(int,input().split())) for i in range(N)]

# 全部買ってクリアできるか判定
all = [i for i in range(N)]
max = getTotal(all)
result = max[0]
for i in range(M):
    if max[i+1] < X:
        result = -1
        print(-1)
        break

if result != -1:
    for i in range(2**N):
        buyList = getIndex("0"*(N-len(bin(i)[2:]))+bin(i)[2:],"1")
        total = getTotal(buyList)

        # クリア変数の定義
        clear = True

        for i in range(M):
            if total[i] < X:
                clear = False
                break
        if clear and total[0] < result:
            result = total[0]
    print(result)

Submission status: Wrong Answer

Solution code:
def main():
    import itertools
    N, M, X = map(int, input().split())
    c_list = []
    a_list = []
    dict = {}
    for i in range(1,N+1) :
        A_list = [A for A in input().split()]
        A_list = list(map(int, A_list))
        c_list.append(A_list[0])
        a_list.append(A_list[1:])
        dict[A_list[0]] = A_list[1:]

    comb_lists = []
    for i in range(1, len(c_list)+1) :
        for comb_list in itertools.combinations(c_list, i) :
            comb_lists.append(list(comb_list))
    #print("comb_lists = %s" % comb_lists)
    result = -1
    for key_list in comb_lists :
        ans = 0
        t = [0] * M
        #print("key_list = %s" % key_list)
        for key in key_list :
            ans = ans + int(key)
            for j in range(M) :
                t[j] = t[j] + dict[key][j]
        #print("t = %s" % t)
        if all(x >= X for x in t) :
            if result == -1 :
                result = ans
            else :
                result = min(result, ans)
    print(result)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
import itertools

n, m, x = [int(x) for x in stdin.readline().rstrip().split()]
c = [[int(y) for y in x.rstrip().split()] for x in stdin.readlines()]
mi = -1
r = 0

for j in range(m):
    li = [x[j+1] for x in c]
    li.sort(reverse=True)
    for i in range(len(li)):
        if sum(li[:i]) > x:
            r = max(r, i)
            break

for h in range(r,n):
    for i in itertools.combinations(c, h):
        cnt = [0]*m
        mon = 0
        for j in i:
            cnt = [cnt[k]+j[k+1] for k in range(len(cnt))]
            mon += j[0]
            if sum(1 for k in cnt if k >= x) == m:
                if mi > mon or mi == -1:
                    mi = mon
                break

print(mi)

Submission status: Wrong Answer

Solution code:
n, m, k = map(int, input().split())
li = []
for t in range(n):
    li.append(list(map(int, input().split())))
price_list = []
for bit in range(1, 2**n):
    index_list = []
    for i in range(n):
        if bit & 1<<i:
            index_list.append(i)

    s = 0
    c = 0
    for t in range(1,m+1):
        for i in index_list:
            s += li[i][t]
        if s >= k:
            c += 1
        else:
            continue

    if c == m:
        p = 0
        for i in index_list:
            p += li[i][0]
        price_list.append(p)

if len(price_list):
    print(price_list)
else:
    print('-1')

Submission status: Wrong Answer

Solution code:
n, m, k = map(int, input().split())
li = []
for t in range(n):
    li.append(list(map(int, input().split())))
price_list = []
for bit in range(1, 2**n):
    index_list = []
    for i in range(n):
        if bit & 1<<i:
            index_list.append(i)

    s = 0
    c = 0
    for t in range(1,m+1):
        for i in index_list:
            s += li[i][t]
        if s >= k:
            c += 1
        else:
            break
    else:
        if c == m:
            p = 0
            for i in index_list:
                p += li[i][0]
            price_list.append(p)

if len(price_list):
    print(price_list)
else:
    print('-1')

Submission status: Wrong Answer

Solution code:
from sys import stdin
import itertools

n, m, x = [int(x) for x in stdin.readline().rstrip().split()]
c = [[int(y) for y in x.rstrip().split()] for x in stdin.readlines()]
mi = -1
r = 0

li = [x[1] for x in c]
li.sort(reverse=True)

for i in range(len(li)):
    if sum(li[:i]) > x:
        r = i
        break

for h in range(r,n):
    for i in itertools.permutations(c, h):
        cnt = [0]*m
        mon = 0
        for j in i:
            cnt = [cnt[k]+j[k+1] for k in range(len(cnt))]
            mon += j[0]
            if sum(1 for k in cnt if k >= x) == m:
                if mi > mon or mi == -1:
                    mi = mon
                break
    if mi != -1:
        break

print(mi)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import itertools

n, m, x = [int(x) for x in stdin.readline().rstrip().split()]
c = [[int(y) for y in x.rstrip().split()] for x in stdin.readlines()]
mi = -1

for h in range(1,n):
    for i in itertools.permutations(c, h):
        cnt = [0]*m
        mon = 0
        for j in i:
            cnt = [cnt[k]+j[k+1] for k in range(len(cnt))]
            mon += j[0]
            if sum(1 for k in cnt if k >= x) == m:
                if mi > mon or mi == -1:
                    mi = mon
                break
    if mi != -1:
        break

print(mi)

Submission status: Wrong Answer

Solution code:
n, m, k = map(int, input().split())
li = []
for t in range(n):
    li.append(list(map(int, input().split())))
price_list = []
for bit in range(1, 2**n + 1):
    index_list = []
    for i in range(n):
        if bit & 1<<i:
            index_list.append(i)

    s = 0
    c = 0
    for t in range(1,m+1):
        for i in index_list:
            s += li[i][t]
        if s >= k:
            c += 1
    else:
        if c == m:
            p = 0
            for i in index_list:
                p += li[i][0]
            price_list.append(p)
if len(price_list):
    print(min(price_list))
else:
    print('-1')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)

inf = 10 ** 5
input = sys.stdin.readline

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

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

ans = inf
for s in range(1 << n):
  cost = 0
  d = [0] * m
  for i in range(n):
    if (s >> i & 1):
      cost += books[i][0]
      for j in range(m):
        d[j] += books[i][j+1]
  ok = True
  for j in range(m):
    if(d[j] < x):
      ok = False
  if ok:
    ans = min(cost, ans)
if (ans == inf):
  print("-1")
else :
  print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)

inf = 10 ** 5
input = sys.stdin.readline

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

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

ans = inf
for s in range(1 << n):
  cost = 0
  d = [0] * m
  for i in range(n):
    if (s >> i & 1):
      cost += books[i][0]
      for j in range(m):
        d[j] += books[i][j+1]
  ok = True
  for j in range(m):
    if(d[j] < x):
      ok = False
  if ok:
    ans = min(cost, ans)
if (ans == inf):
  print(-1)
else :
  print(ans)

Submission status: Wrong Answer

Solution code:
n, m, k = map(int, input().split())
li = []
for t in range(n):
    li.append(list(map(int, input().split())))
price_list = []
for bit in range(1, 1<<n):
    index_list = []
    for i in range(n):
        if bit & 1<<i:
            index_list.append(i)

    s = 0
    c = 0
    for t in range(1,m+1):
        for i in index_list:
            s += li[i][t]
        if s >= k:
            c += 1
    else:
        if c == m:
            p = 0
            for i in index_list:
                p += li[i][0]
            price_list.append(p)
if len(price_list):
    print(min(price_list))
else:
    print('-1')

Submission status: Wrong Answer

Solution code:
#3 3 10
#60 2 2 4
#70 8 7 9
#50 2 3 9

n, m, k = map(int, input().split())
li = []
for t in range(n):
    li.append(list(map(int, input().split())))
price_list = []
for bit in range(1, 1<<n):
    index_list = []
    for i in range(n):
        if bit & 1<<i:
            index_list.append(i)

    s = 0
    c = 0
    for t in range(1,m+1):
        for i in index_list:
            s += li[i][t]
        if s >= k:
            c += 1
    else:
        if c == m:
            p = 0
            for i in index_list:
                p += li[i][0]
            price_list.append(p)
if len(price_list):
    print(min(price_list))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
from sys import stdin
n, m, x = [int(x) for x in stdin.readline().rstrip().split()]
c = [[int(y) for y in x.rstrip().split()] for x in stdin.readlines()]

mi = -1

for i in range(len(c)-1):
    _li = [x for x in c[i] if x != c[i][0]]
    mon = c[i][0]

    for j in range(i + 1, len(c)):
        li = [_li[k] + c[j][k + 1] for k in range(len(_li))]
        mon += c[j][0]
        if sum(1 for k in li if k >= x) == m:
            if mi > mon or mi == -1:
                mi = mon
            break
        else:
            _li = li


print(mi)

Submission status: Wrong Answer

Solution code:
from sys import stdin
n, m, x = [int(x) for x in stdin.readline().rstrip().split()]
c = [[int(y) for y in x.rstrip().split()] for x in stdin.readlines()]

c.sort()
mi = -1

for i in range(len(c)-1):
    _li = [x for x in c[i] if x != c[i][0]]
    mon = c[i][0]

    for j in range(i + 1, len(c)):
        li = [_li[k] + c[j][k + 1] for k in range(len(_li))]
        mon += c[j][0]
        if sum(1 for k in li if k >= x) == m:
            if mi > mon or mi == -1:
                mi = mon
            break
        else:
            _li = li


print(mi)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

data_all = []
c_min = INF

for i in range(N**2):
    data_tmp = [0]*M
    c = 0
    for j in range(N):
        if((i>>j) & 1):
            for k in range(M):
                data_tmp[k] += data[j][k+1]
            c += data[j][0]
    if(min(data_tmp) >= X):
        c_min = min(c, c_min)

if(c_min == INF):
    print(-1)
else:
    print(c_min)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

data = [list(map(int, input().split())) for _ in range(N)]
INF = float('inf')

data_all = []
c_min = INF

for i in range(N**2):
    data_tmp = [0]*M
    c = 0
    for j in range(N):
        if((i>>j) & 1):
            for k in range(M):
                data_tmp[k] += data[j][k+1]
            c += data[j][0]
    if(min(data_tmp) >= X):
        c_min = min(c, c_min)

if(c_min == INF):
    print(-1)
else:
    print(c_min)

Submission status: Wrong Answer

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

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

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

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

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

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

    while min(exps) < X:

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

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

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

    print(price)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

data_all = []
c_min = INF

for i in range(N**2):
    data_tmp = [0]*M
    c = 0
    for j in range(N):
        if((i>>j) & 1):
            for k in range(M):
                data_tmp[k] += data[j][k+1]
            c += data[j][0]
    if(min(data_tmp) >= X):
        c_min = min(c, c_min)

if(c_min == INF):
    print(-1)
else:
    print(c_min)

Submission status: Wrong Answer

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

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

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

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

books = sorted(
    books,
    key=lambda x: x['price']
)
books = sorted(
    books,
    key=lambda x: abs(X - x['get_exp'][0]),
)

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

    while min(exps) < X:

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

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

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

    print(price)

Submission status: Wrong Answer

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

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

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

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

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

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

    while min(exps) < X:

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

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

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

    print(price)

Submission status: Wrong Answer

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

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

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

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

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

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

    while min(exps) < X:

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

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

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

    print(price)

Submission status: Wrong Answer

Solution code:
N,M,X = list(map(int,input().split()))
C = []
A = []
for i in range(N):
  CA = list(map(int,input().split()))
  C.append(CA[0])
  A.append(CA[1:])
min_value = -1

for i in range(2**N):
  cost = 0
  a = [0 for j in range(M)]
  for n in range(N):
    if format(i, '#014b')[-n] == "0":
      cost += C[n]
      a = [l+r for l,r in zip(a,A[n])]
  else:
    if all([a_ >= X for a_ in a]) and (min_value == -1 or cost<min_value):

      min_value = cost
print(min_value)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

data_a = np.sum(data, axis=0)
#print(data_all - data[1])
data_all_zero = []
data_all = []
data_nolma = []
data_nolma.append(0)
for i in range(M + 1):
    data_all_zero.append(data_a[i])

data_all.append(data_all_zero)
#print("data_all:", data_all)

for i in range(M):
    data_nolma.append(X)

#print("data_nol:", data_nolma)

c = 100000

for i in range(N):
    for j in range(N):
        for k in range(len(data_all)):
            #print("data[j]:", data[j])
            #print("len:", len(data_all))
            data_tmp = [x - y for (x,y) in zip(data_all[k], data[j])]
            #print("data_tmp:", data_tmp)
            data_tmp_nol = [x - y for (x,y) in zip(data_tmp, data_nolma)]
            #print("data_tmp_nol:", data_tmp_nol)
            if(min(data_tmp_nol) >= 0):
                data_all.append(data_tmp)
                c = min(c, data_tmp[0])



#print(data_all)
#data_all.sort()

if(c ==100000):
    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):
    t = [int(j) for j in input().split()]
    c.append(t.pop(0))
    a.append(t)

me = [x] * m
min = sum(c)
cost = 0

def f(me, books, ctbl, cost):
    global min 
    if len(books) == 0:
        return
    for i,b in enumerate(books):
        t = tuple(map(lambda x:x[0]-x[1], zip(me, b)))
        if len(tuple(filter(lambda x:x>0, t))) > 0:
            f(t, books[i+1:], ctbl[i+1:], cost+ctbl[i])
        else:
            if min > cost+ctbl[i]:
                min = cost+ctbl[i]
    f(me, books[1:], ctbl[1:], cost)

f(me, a, c, 0)
if sum(c) == min:
    print(-1)
else:
    print(min)

Submission status: Wrong Answer

Solution code:
INF=100100100

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:])
cost=INF
for i in range(n**2):
    ab=[0]*m
    tmp=0
    for j in range(n):
        idx=i>>j & 1
        if(idx):
            tmp+=c[j]
            for k in range(m):
                ab[k]+=a[j][k]
    for k in range(m):
        if(ab[k]<x):break
    else:cost=min(cost,tmp)
if(INF==cost):print(-1)
else:print(cost)

Submission status: Wrong Answer

Solution code:
INF=100100100

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:])
cost=INF
for i in range(n**2-1):
    ab=[0]*m
    tmp=0
    for j in range(n):
        idx=i>>j & 1
        if(idx):
            tmp+=c[j]
            for k in range(m):
                ab[k]+=a[j][k]
    for k in range(m):
        if(ab[k]<x):break
    else:cost=min(cost,tmp)
if(INF==cost):print(-1)
else:print(cost)

Submission status: Wrong Answer

Solution code:
INF=100100100

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:])
print(a)
cost=INF
for i in range(n**2-1):
    ab=[0]*m
    tmp=0
    for j in range(n):
        idx=i>>j & 1
        if(idx):
            tmp+=c[j]
            for k in range(m):
                ab[k]+=a[j][k]
    for k in range(m):
        if(ab[k]<x):break
    else:cost=min(cost,tmp)
if(INF==cost):print(-1)
else:print(cost)

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
book_list = []
cost = [0] * (2 ** N)

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

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

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

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
book_list = []
cost = [0] * (2 ** N)

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

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

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

Submission status: Wrong Answer

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

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

print("-1")

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
book_list = []
cost = [0] * (2 ** N)

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

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

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

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
book_list = []
cost = [0] * (2 ** N)

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

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

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

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
book_list = []
cost = [0] * (2 ** N)

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

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

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

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
book_list = []
cost = [0] * (2 ** N)

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

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

if flag  == 1:
    x = -1
    print(x)
else:
    print(min(cost_paform))

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
book_list = []
cost = [0] * (2 ** N)

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

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

print(ans)