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())
a=[]
for i in range(n):
    ai=list(map(int,input().split()))
    a.append(ai)
mini=10000000

#全探索
for i in range(2**n):
    d=[]
    for j in range(n):
        if((i>>j)and 1):
            d.append(j)
    b=[0 for k in range(m)]
    #能力
    c=0
    #お金
    for j in d:
        c+=a[j][0]
        for k in range(m):
            b[k]+=a[j][k+1]
    l=0
    for j in b:
        if j<x:
            l=1
    if l==0:
        mini=min(mini,c)

if mini==10000000:
    print(-1)
else: print(mini)

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
a=[[] for ii in range(n)]
for ii in range(n):
  a[ii]=list(map(int,input().split()))
a.sort(reverse=True)
#print(a)

r=[0]*(m+1)
for ii in range(m+1):
  r[ii]+=sum([a[jj][ii] for jj in range(n)])

import numpy as np
def lambda_d(ii,r,km):
  rx=[r[jj]-a[ii][jj] for jj in range(m+1)]
  kx=[km[jj]-a[ii][jj] for jj in range(m+1)]
  if ii==n-1:
    #print(kx[1:m+1])
    if max(kx[1:m+1])>0:
      return 0,False
    else:
      return a[ii][0],True
    
  lt,tft=lambda_d(ii+1,rx,kx)
  lf,tff=lambda_d(ii+1,r,km)
  if tft or tff:
    #print(ii,tff,tft,lf,lt+a[ii][0])
    if not tft:
      return lf,tff
    elif not tff:
      return lt+a[ii][0],tft
    else:
      return min(lt+a[ii][0],lf),True
  else:
    return 0,False

km=[x]*(m+1)
l0,tf=lambda_d(0,r,km)
if not tf:
  print(-1)
else:
  print(l0)

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
a=[]
c=[]
inf=10**9
result=inf
for i in range(n):
    b=list(map(int,input().split()))
    c.append(b[0])
    a.append(b[1:])
    
for i in range(1<<n):
  cnt=0
  rikaido=[0]*m
  for j in range(n):
    if (i>>j)&1:
      for k in range(m):
        rikaido[k]+=a[j][k]
        cnt+=c[j]
    else:
      pass
  if min(rikaido)>=x:
    result=min(result,cnt)

if result==inf:
  print(-1)
else:
  print(result)

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
a=[[] for ii in range(n)]
for ii in range(n):
  a[ii]=list(map(int,input().split()))
a.sort(reverse=True)
r=[0]*(m+1)
for ii in range(m+1):
  r[ii]+=sum([a[jj][ii] for jj in range(n)])
#print(r)
r0=r[0]
rx=[0]*(m+1)
for jj in range(n):
  rx=[r[ii]-a[jj][ii] for ii in range(m+1)]
  if min(rx[1:m+1])>=x:
    r=rx
if r[0]==r0:
  print(-1)
else:
  print(r[0])

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M,X= map(int,input().split())
a = []
d = 0
e = False
f = []
z = 0
for i in range(N):
    a.append([])

for i in range(N):
    a[i]= [int(i) for i in input().split()]

for i in range(2 ** N):
    b = np.array([0 for _ in range(M + 1)])
    d = True
    for j in range (N):

        if ((i >> j) & 1):
            b = np.array(a[j]) + b
    print(b)
    z = z + 1
    for k in range(M):
        if b[k + 1] < X:
            d = False
    if d:
        f.append(b[0].tolist())
        e = True
if e:
    print(min(f))
else:
    print("-1")

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M,X= map(int,input().split())
a = []
d = 0
e = False
f = []
for i in range(N):
    a.append([])

for i in range(N):
    a[i]= [int(i) for i in input().split()]

for i in range(2 ** N):
    b = np.array([0 for _ in range(M + 1)])
    d = True
    for j in range(M):
        if ((i >> j) & 1):
            b = np.array(a[j]) + b
    for k in range(M-1):
        if b[k + 1] < X:
            d = False
    if d:
        f.append(b[0].tolist())
        e = True

if e:
    print(min(f))
else:
    print("-1")

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M,X= map(int,input().split())
a = []
d = 0
e = False
f = []
for i in range(N):
    a.append([])

for i in range(N):
    a[i]= [int(i) for i in input().split()]

for i in range(2 ** N):
    b = np.array([0 for _ in range(M + 1)])
    d = True
    for j in range(M):
        if ((i >> j) & 1):
            b = np.array(a[j]) + b
        if j == (M - 1):
            for k in range(M-1):
                if b[k + 1] < X:
                    d = False
            if d:
                f.append(b[0].tolist())
                e = True

if e:
    print(min(f))
else:
    print("-1")

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M,X= map(int,input().split())
a = []
d = 0
e = False
f = []
for i in range(N):
    a.append([])

for i in range(N):
    a[i]= [int(i) for i in input().split()]

for i in range(2 ** N):
    b = np.array([0 for _ in range(M + 1)])
    d = True
    for j in range(M):
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            b = np.array(a[j]) + b
        if j == (M - 1):
            for k in range(M-1):
                if b[k + 1] < X:
                    d = False
            if d:
                f.append(b[0].tolist())
                e = True

if e:
    print(min(f))
else:
    print("-1")

Submission status: Wrong Answer

Solution code:
n,m,x = map(int, input().split(" "))
hon = []
check = False
for i in range(n):
    hon.append(list(map(int, input().split(" "))))
mini = n * (10 ** 10)
for bit in range(2 ** n):
    nouryoku = [0 for k in range(m + 1)]
    for j in range(n):
        mask = 1 << j
        if bit&mask:
            for k in range(m + 1):
                nouryoku[k] += hon[j][k]
    temp = 1
    for i in range(m + 1):
        temp *= nouryoku[i] // x
    if temp >= 1:
        check = True
        if nouryoku[0] < mini:
            mini = nouryoku[0]
if check:
    print(mini)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n,m,x = map(int, input().split(" "))
hon = []
for i in range(n):
    hon.append(list(map(int, input().split(" "))))
mini = n * (10 ** 5)
for bit in range(2 ** n):
    nouryoku = [0 for k in range(m + 1)]
    for j in range(n):
        mask = 1 << j
        if bit&mask:
            for k in range(m + 1):
                nouryoku[k] += hon[j][k]
    temp = 1
    for i in range(m + 1):
        temp *= nouryoku[i] // x
    if temp >= 1:
        if nouryoku[0] < mini:
            mini = nouryoku[0]
if mini == n * (10 ** 5):
    print(-1)
else:
    print(mini)

Submission status: Wrong Answer

Solution code:
n,m,x = map(int, input().split(" "))
hon = []
for i in range(n):
    hon.append(list(map(int, input().split(" "))))
mini = n * (10 ** 5)
for bit in range(2 ** n):
    nouryoku = [0 for k in range(m + 1)]
    for j in range(n):
        mask = 1 << j
        if bit&mask:
            for k in range(m + 1):
                nouryoku[k] += hon[j][k]
    temp = 1
    for i in range(m + 1):
        temp *= nouryoku[i] // x
    if temp >= 1:
        if nouryoku[0] < mini:
            mini = nouryoku[0]
if mini == 5 * (10 ** 5):
    print(-1)
else:
    print(mini)

Submission status: Wrong Answer

Solution code:
n,m,x = map(int, input().split(" "))
hon = []
for i in range(n):
    hon.append(list(map(int, input().split(" "))))
mini = 5 * (10 ** 5)
for bit in range(2 ** n):
    nouryoku = [0 for k in range(m + 1)]
    for j in range(n):
        mask = 1 << j
        if bit&mask:
            for k in range(m + 1):
                nouryoku[k] += hon[j][k]
    temp = 1
    for i in range(m + 1):
        temp *= nouryoku[i] // x
    if temp >= 1:
        if nouryoku[0] < mini:
            mini = nouryoku[0]
if mini == 5 * (10 ** 5):
    print(-1)
else:
    print(mini)

Submission status: Wrong Answer

Solution code:
data = input().split()
n = int(data[0])
m = int(data[1])
x = int(data[2])

c = []
a = []
cost = 10 ** 5 + 1

for i in range(n):
    data = input().split()
    c.append(int(data[0]))
    a.append([int(j) for j in data[1:len(data)]])

for i in range(2**n):
    bin_s = format(i, f'0{str(n)}b')
    now_skill = [0] * m
    now_cost = 0
    for j in range(len(bin_s)):
        if bin_s[j] == '1':
            now_cost += c[j]
            for k in range(m):
                now_skill[k] += a[j][k]
        is_ok = True
        for k in now_skill:
            if k < x:
                is_ok = False
                break
        if is_ok:
            cost = min(cost, now_cost)
if cost == 10 ** 5 + 1:
    cost = -1
print(cost)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m,x=map(int,input().split())
flg=np.zeros((m+1),dtype=int)
minimn=-1
data=np.zeros((n,m+1))
for i in range(n):
    data[i]=list(map(int,input().split()))
for i in range(2**n):
    flg=np.zeros((m+1))
    for j in range(n):
        if (i>>j)&1:
            flg+=data[j]
    if all(flg[1:]>=x):
        if minimn==-1:
          minimn=flg[0]
        elif flg[0]<minimn:
          minimn=flg[0]
print(minimn)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m,x=map(int,input().split())
flg=np.zeros((m+1),dtype=int)
minimn=10**5
data=np.zeros((n,m+1))
for i in range(n):
    data[i]=list(map(int,input().split()))
for i in range(2**n):
    flg=np.zeros((m+1))
    for j in range(n):
        if (i>>j)&1:
            flg+=data[j]
    if all(flg[1:]>=x):
        if flg[0]<minimn:
            minimn=flg[0]
if minimn==10**5:
    minimn=-1
    print(minimn)
else:
    print(int(minimn))

Submission status: Wrong Answer

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

a = [[] for _ in range(n)]
c = [0] * n

for i in range(n):
    t = [int(e) for e in input().split()]
    c[i],a[i] = t[0],t[1:]

min_cash = 120001

for j in range(2**n):
    sum_cash = 0
    al = [0]*m
    for k in range(n):
        if ((j>>k) & 1):
            sum_cash += c[k]
            for l in range(m):
                al[l] += a[k][l]
       
    f = 1   
    for j in range(m):
        if al[j] < x:
            f = 0

    if f:
        min_cash = min(min_cash,sum_cash)

if min_cash == 120001:
    min_cash = -1

print(min_cash)

Submission status: Wrong Answer

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

a = [[] for _ in range(n)]
c = [0] * n

for i in range(n):
    t = [int(e) for e in input().split()]
    c[i],a[i] = t[0],t[1:]

min_cash = 120001

for j in range(2**n):
    sum_cash = 0
    al = [0]*m
    for k in range(n):
        if ((j>>k) & 1):
            sum_cash += c[k]
            for l in range(m):
                al[l] += a[k][l]
        
    if min(al) >= x:
        min_cash = min(min_cash,sum_cash)

if min_cash == 120001:
    min_cash = -1

print(min_cash)

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
books = []
ans = float('inf')
for _ in range(n):
    book = list(map(int, input().split()))
    books.append(book)

for i in range(n**2):
    count = [0] * m
    book_price = 0
    for j in range(n):
        if (i >> j) & 1:
            book_price += books[j][0]
            for k in range(1, m+1):
                count[k-1] += books[j][k]
    check = True
    for j in count:
        if j < x:
            check = False
            break
    if check:
        ans = min(ans, book_price)
if ans == float('inf'):
    print('-1')
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
books = []
book_total_price = []
for _ in range(n):
    book = list(map(int, input().split()))
    books.append(book)

for i in range(n**2):
    reference_book = []
    book_price = 0
    for j in range(n):
        if (i >> j) & 1:
            reference_book.append(books[j])
            book_price += books[j][0]
    if reference_book != []:
        err = 0
        for k in range(1, m+1):
            r = [row[k] for row in reference_book]
            if sum(r) < x:
                err += 1
        if err == 0:
            book_total_price.append(book_price)
if book_total_price == []:
    print('-1')
else:
    print(min(book_total_price))

Submission status: Wrong Answer

Solution code:
n,m,x = map(int, input().split())
result = 10**9
A=[]
C=[]
for _ in range(n):
	books=list(map(int, input().split()))
	C.append(books[0])
	A.append(books[1:])
for i in range(1<<n):
	cnt = 0
	rikaido = [0]*m
	for j in range(n):
		if (i>>j)&1:
			for k in range(m):
				rikaido[k]+=A[j][k]
			cnt += C[j]
		else:
			pass
	if min(rikaido)>=x:
		result = min(result, cnt)
if result == 10*9:
	print(-1)
else:
	print(result)

Submission status: Wrong Answer

Solution code:
import numpy as np,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M,X = LI()
CA = np.array([LI() for _ in range(N)])
ans = float('INF')
for i in range(N**2):
    bit = np.array([[i>>j&1 for j in range(N)]]).T
    temp = (CA*bit).sum(axis=0)
    if (temp[1:]>=X).all():
        ans = min(ans,temp[0])
print(ans if ans!=float('INF') else -1)

Submission status: Wrong Answer

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

for i in range(n):
    tmp = list(map(int, input().split()))
    c.append(tmp[0])
    a.append([])
    
    for j in range(m):
        a[i].append(tmp[j])

ab = []
for i in range(m):
    sum = 0
    for j in range(n):
        sum += a[j][i]
    ab.append(bool(sum > x))

print(300 if all(ab) else -1)

Submission status: Wrong Answer

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n, m, x = readmi()

p = []
v = [0] * (m + 1)
for i in range(n):
    p.append(readl())
    for j in range(m + 1):
        v[j] += p[-1][j]

p.sort(reverse=True)
count = 0
for i in range(n):
    flg = True
    for j in range(1, m + 1):
        if v[j] - p[i][j] < x:
            flg = False
    if flg:
        for j in range(m + 1):
            v[j] -= p[i][j]
for i in range(1, m + 1):
    if v[i] < x:
        print(-1)
        exit()
print(v[0])

Submission status: Wrong Answer

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n, m, x = readmi()

p = []
v = [0] * (m + 1)
for i in range(n):
    p.append(readl())
    for j in range(m + 1):
        v[j] += p[-1][j]

p.sort(reverse=True)
count = 0
for i in range(n):
    flg = True
    for j in range(1, m + 1):
        if v[j] - p[i][j] < x:
            flg = False
    if flg:
        count += 1
        for j in range(m + 1):
            v[j] -= p[i][j]
if count > 0:
    print(v[0])
else:
    print(-1)

Submission status: Wrong Answer

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

for i in range(N):
	lines.append(list(map(int,input().split())))
pricemin = 1500000
for i in range(2**N):
	price = 0
	count = 0
	A = [0]*M
	for j in range(N):
		if ((i >> j) & 1):
			for k in range(M):
				A[k] += lines[j][k+1]
			price += lines[j][0]
	for j in range(M):
		if A[j] >= X:
			count += 1
	if count == M and pricemin > price:
		pricemin = price
if pricemin == 1000000:
	print('-1')
else:
	print(pricemin)

Submission status: Wrong Answer

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

for i in range(N):
	lines.append(list(map(int,input().split())))
pricemin = 1000000
for i in range(2**N):
	price = 0
	count = 0
	A = [0]*M
	for j in range(N):
		if ((i >> j) & 1):
			for k in range(M):
				A[k] += lines[j][k+1]
			price += lines[j][0]
	for j in range(M):
		if A[j] >= X:
			count += 1
	if count == M and pricemin > price:
		pricemin = price
if pricemin == 1000000:
	print('-1')
else:
	print(pricemin)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N, M, X = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(N)]
n = len(C)
m = -1
for i in range(2 ** n):
    A = [0 for i in range(M+1)]
    total = 0
    for j in range(n):
        if((i >> j) & 1):
            A = [a + b for a, b in zip(A, C[j])]
            B = [k for k in range(M) if A[k] < X]
            if len(B) == 0:
                if m == -1:
                    m = A[0]
                else:
                    m = min(m, A[0])
                break
print(m)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N, M, X = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(N)]
n = len(C)
m = -1
for i in range(2 ** n):
    A = [0 for i in range(M)]
    total = 0
    for j in range(n):
        if((i >> j) & 1):
            A = [a + b for a, b in zip(A, C[j])]
            B = [k for k in range(M) if A[k] < X]
            if len(B) == 0:
                if m == -1:
                    m = A[0]
                else:
                    m = min(m, A[0])
                break
print(m)

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
result_3=[]
result_2=[]
for i in range(n):
  add_list = a[i]
  for j in range(1,n-i):
    for o in range(n-j-i):
      add_list = [x+y for (x,y) in zip(add_list,a[i+j+o])]
      result_1=[]
      for k in range(1,m+1):
        if add_list[k]>=x:
          result_1.append(add_list[k])
      if len(result_1) == m:
        result_2.append(add_list)
for l in range(len(result_2)):
  result_3.append(result_2[l][0])
if result_3:
  print(min(result_3))
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
inputs = list(map(lambda x: int(x), input().split()))

tmp = []
i = 0
while(i < inputs[0]):
    tmp.append(list(map(lambda x: int(x), input().split())))
    i += 1

money = 0
counter = [0] * inputs[1]

def hantei(count, x):
    flag = True
    for c in count:
        if c < x:
            flag = False
            break
    return flag

for book in sorted(tmp, key=lambda x: x[0]):
    money += book[0]
    if hantei([x + y for x ,y in zip(counter, book[1:len(book)])], inputs[2]):
        break

if hantei([x + y for x ,y in zip(counter, book[1:len(book)])], inputs[2]):
    print(money)
else:
    print('-1')

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
book = []
for i in range(n):
    a = [int(e) for e in input().split()]
    book.append(a)

min_cash = 120001

for j in range(2**n):
    sum_cash = 0
    al = [0]*m
    for k in range(n):
        if ((j>>k) & 1):
            sum_cash += book[k][0]
            for l in range(m):
                al[l] += book[k][l+1]
        
    if min(al) >= x:
        min_cash = min(min_cash,sum_cash)

if min_cash == 120001:
    print(-1)
else:
    print(min_cash)

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
result_3=[]
result_2=[]
for i in range(n):
  add_list = a[i]
  for j in range(1,n-i):
    add_list = [x+y for (x,y) in zip(add_list,a[i+j])]
    result_1=[]
    for k in range(1,m+1):
      if add_list[k]>=x:
        result_1.append(add_list[k])
    if len(result_1) == m:
      result_2.append(add_list)
for l in range(len(result_2)):
  result_3.append(result_2[l][0])
if result_3:
  print(min(result_3))
else:
  print(-1)

Submission status: Wrong Answer

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

book_list = [tuple(map(int, input().strip().split())) for _ in range(N)]

most_cheep = 10**5*12
for pattern in range(1 << N):
    understanding_list = [0]*M
    cost_list = []
    for n_bit in range(N):
        if (pattern >> n_bit)&1:
            for m in range(M):
                understanding_list[m] += book_list[n_bit][m+1]
            cost_list.append(book_list[n_bit][0])
    for understanding in understanding_list:
        if understanding < X:
            break
    else:
        most_cheep = min(most_cheep, sum(cost_list))

if most_cheep == 10**5*12: most_cheep=-1

print(most_cheep)

Submission status: Wrong Answer

Solution code:
N,M,X = map(int, input().split())
D = []
ans = [0] * (M+1)
for i in range(N):
  A = list(map(int, input().split()))
  D.append(A)

for i in range(N):
  kl = sum(D[i])-D[i][0]
  if kl >= X:
    ans[0] += D[i][0]
    for j in range(1,M+1):
      ans[j] += D[i][j]
    flg = 0
    for k in range(1,len(ans)):
      if ans[k] >= X:
        flg += 1
    if flg > M:
      print(ans[0])
      exit()

Submission status: Wrong Answer

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

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

_books = list(zip(*books))
total_points = []
total_price = sum(_books[0])

for l in _books[1:]:
    total = sum(l)
    if total < X:
        print('-1')
        exit()
    total_points.append(total)

for book in sorted(books, reverse=True):
    if all([True if total - point >= X else False
                 for total, point in zip(total_points, book[1:])]):
        for i in range(M):
            total_points[i] -= book[i+1]
        total_price -= book[0]

print(total_price)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m,x=map(int,input().split())
flg=np.zeros((m+1),dtype=int)
minimn=10**5
data=np.zeros((n,m+1))
for i in range(n):
    data[i]=list(map(int,input().split()))
for i in range(2**n):
    flg=np.zeros((m+1))
    for j in range(n):
        if (i>>j)&1:
            flg+=data[j]
    if all(flg[1:]>=x):
        if flg[0]<minimn:
            minimn=flg[0]
if minimn==10**5:
    print(-1)
else:
    print(int(minimn))

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m,x=map(int,input().split())
flg=np.zeros((m+1),dtype=int)
minimn=10**5
data=np.zeros((n,m+1))
for i in range(n):
    data[i]=list(map(int,input().split()))
for i in range(2**n):
    flg=np.zeros((m+1))
    total=0
    for j in range(n):
        if (i>>j)&1:
            total+=data[j][0]
            for k in range(m):
                flg[k]+=data[j][k+1]
                if x<flg[k]:
                    flg[k]=x
    if sum(flg)==x*m:
        if total<minimn:
            minimn=total
if minimn==10**5:
    print(-1)
else:
    print(int(minimn))

Submission status: Wrong Answer

Solution code:
from itertools import combinations
N,M,X=[int(x) for x in input().split()]
L=[]
for _ in range(N):
  L.append([int(x) for x in input().split()])

Smin=-1
for i in range(N):
  for t in combinations(L,i):
    S=0
    A=[0]*M
    for l in t:
      S+=l[0]
      for x in range(M):
        A[x]+=l[1+x]
    ok=True
    for x in range(M):
      if A[x] < X:
        ok=False
        break
    if ok and (Smin==-1 or Smin>S):
      Smin=S
print(Smin)

Submission status: Wrong Answer

Solution code:
import numpy as np
num=list(map(int,input().split()))
m=[0]*num[1]
minimn=10**5
data=np.ones((num[0],(num[1]+1)),dtype=int)
for i in range(0,num[0]):
    data[i]=list(map(int,input().split()))
for i in range(2**num[0]):
    m=[0]*num[1]
    total=0
    for j in range(num[0]):
        if (i>>j)&1:
            total+=data[j][0]
            for k in range(num[1]):
                m[k]+=data[j][k+1]
                if num[2]<m[k]:
                    m[k]=num[2]
    if sum(m)==10*num[1]:
        if total<minimn:
            minimn=total
if minimn==10**5:
    print(-1)
else:
    print(minimn)

Submission status: Wrong Answer

Solution code:
input_line = input().split()
book_num = int(input_line[0])
algo_num = int(input_line[1])
algo_goal = int(input_line[2])

book_info = []

for i in range(book_num):
    book = input().split()
    book_info.append(list(map(int, book)))

minimum = 100000000

for i in range(2 ** book_num):
    flag = True
    study = []
    study_list = []
    for j in range(book_num):
        if (i >> j) & 1:
            study.append(book_info[j])
            study_list.append(j)
    for j in range(1, algo_num):
        goal = 0
        for k in range(len(study)):
            goal += study[k][j]
        if goal < algo_goal:
            flag = False
            study.clear()
            study_list.clear()
            break
    if flag == True:
        price = 0
        for j in range(len(study_list)):
            price += study[j][0] # 値段
        if minimum > price:
            minimum = price

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m,x = map(int, input().split())

#A = np.zeros((n, m))
CA = np.zeros((n,m+1))

for i in range(n):
    CA[i]=list(map(int, input().split()))
    # C[i],A[i]=T[0],T[1:]
#print(A,C)

min_cost = 9999999999999999

for i in range(2**n):
    T = np.zeros((m+1))
    for j in range(n):
        if i&(2**j) > 0:
            T += CA[j]
    if all(T[1:] >= x):
        min_cost = min(min_cost,T[0])        

print(min_cost)

Submission status: Wrong Answer

Solution code:
input_line = input().split()
book_num = int(input_line[0])
algo_num = int(input_line[1])
algo_goal = int(input_line[2])

book_info = []

for i in range(book_num):
    book = input().split()
    book_info.append(list(map(int, book)))

minimum = 10000000

for i in range(2 ** book_num):
    flag = True
    study = []
    book_list = []
    for j in range(book_num):
        if (i >> j) & 1:
            study.append(book_info[j])
            book_list.append(j)
    for j in range(1, algo_num):
        goal = 0
        for k in range(len(study)):
            goal += study[k][j]
        if goal < algo_goal:
            flag = False
            study.clear()
            book_list.clear()
            break
    if flag == True:
        price = 0
        for j in range(len(book_list)):
            price += study[j][0]
        if minimum > price:
            minimum = price

if minimum == 10000000:
    print('-1')
else:
    print(minimum)

Submission status: Wrong Answer

Solution code:
N,M,X = map(int,input().split())
C = []
A = []
for n in range(N):
    temp = [int(i) for i in input().split()]
    C.append(temp[0])
    A.append(temp[1:])
import numpy as np
np_A = np.array(A)
min_cost = 10**6
if np.all(np_A.sum(axis=0) >= X):
    for i in range(2**N):
        P = str(bin(i)).replace("0b","").zfill(N)
        score = np.zeros(M)
        cost = 0
        for j,p in enumerate(P):
            if p == "1":
                cost += C[j]
                score += np_A[j]
        if np.all(score >= X):
            min_cost = min(min_cost,cost)
    print(min_cost)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(N)]
ans = 10**20

for mask in range(2**N):
    C = [0]*M
    cst = 0
    for i in range(N):
        if (mask>>i)&1:
            cst += x[i][0]
            for j in range(1, M+1):
                C[j-1] += x[i][j]
    if min(C) >= X:
        ans = min(ans, cst)

if ans < 10**20:
    print(ans)

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
nedan=[]
grade=[]
ans=-1
for i in range(n):
  s=list(map(int,input().split())) 
  nedan.append(s.pop(0))
  grade.append(s)
#print(nedan)
#print(grade)

for i in range(2**n):
  shopping=[]
  total_grade=[]
  for j in range(n):
    if (( i >> j ) & 1):
      shopping.append(nedan[j])
      print(nedan[j])
      total_grade.append(grade[j])
      print(grade[j])

  t=sum(shopping)
  print(t)
  print(shopping)
  print(total_grade)
  sum_grade=[]
  for j in range(m):
    s=0
    for k in range(len(total_grade)):
        s+=total_grade[k][j]
    sum_grade.append(s)

  if sum_grade >=[x]*len(total_grade):
    ans=t
    break
print(t)
if ans==-1:
  print(-1)

else:
  print(ans)

Submission status: Wrong Answer

Solution code:
N,M,X=map(int,input().split())
S=[input().split() for _ in range(N)]
mintotal=10**9

for i in range(2**N):
    alg=[0]*M
    total=0
    for j in range(N):
        if ((i >> j) & 1):
            for k in range(M):
                alg[k]+=int(S[j][k + 1])
            total+=int(S[j][0])

    for l in range(M):
        if alg[l] < X:
            break
        else:
          mintotal = min(mintotal,total)

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

n,m,k = map(int,input().split())
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。
x=[[0] * (m+1) for i in range(2**n)] 
#print(listA)
for i in range(2 ** n):
    for j in range(n):
        if((i >> j) & 1 ):
            for l in range(m+1):
                x[i][l] += listA[j][l]
            
#print(x)

cnt = 10**10
t = [k] * (m+1)
#print(t)
f = 0
for i in x:
    #print(i)
    u = 0
    for j in range(2, m):
        #print(1)
        if i[j] < t[j]:
            u = 1
    if u != 1:
        if cnt >= i[0]:
            cnt = i[0]
            f = 1
    #print(cnt)    
if f != 0:
    print(cnt)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

n,m,k = map(int,input().split())
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。
x=[[0] * (m+1) for i in range(2**n)] 
#print(listA)
for i in range(2 ** n):
    for j in range(n):
        if((i >> j) & 1 ):
            for l in range(m+1):
                x[i][l] += listA[j][l]
            
#print(x)

cnt = 10**10
t = [k] * (m+1)
#print(t)
f = 0
for i in x:
    #print(i)
    u = 0
    for j in range(0, m):
        #print(1)
        if i[j] < t[j]:
            u = 1
    if u != 1:
        if cnt >= i[0]:
            cnt = i[0]
            f = 1
    #print(cnt)    
if f != 0:
    print(cnt)
else:
    print(-1)