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 = [list(map(int, input().split())) for _ in range(N)]

ans = 10**9 + 10

for i in range(2**N):
    score = [0] + [X] * (M)
    for j in range(N):
        if ((i >> j) & 1):
            for k in range(M+1):
                score[k] -= A[j][k]
    for l in range(1, M):
        if score[l] > 0:
            break
        else:
          x = abs(score[0])
          ans = min(ans, x)

if ans == 10**9+10:
    ans = -1

print(ans)

Submission status: Wrong Answer

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

INF = 30
ans = 1 << INF

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

for i in range(1, 2**N):
    tmp = 0
    skill = [0] * M
    for j in range(N):
        if i >> j & 1:
            tmp += data[j][0]
            for k in range(M):
                skill[k] += data[j][k - 1]
    if min(skill) >= X and tmp < ans:
        ans = tmp

if ans == 1 << INF:
    print('-1')
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
c=[list(map(int,input().split())) for i in range(n)]
ans=10**9

for i in range(2**n):
  b=[0]*m
  count=0
  en=0
  for j in range(n):
    if (i>>j)&1:
      en=en+c[j][0]
      for f in range(m):
        b[f]+=c[j][f+1]
      for f in range(m):
        if b[f]>=x:
          count+=1
          print(b[f])
        if count==m:
          if en<ans:
            ans=en

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

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
a = list(list(map(int, input().split())) for _ in range(n))

#print(n, m, x, a)

#0b00・・・０~0b111・・・１を全部作成
cost_abl = []
cost_lis = []
abl_lis = []
for i in range(1 << n):
    cost = 0
    abl_sum = [0] * m
    #print(abl_sum)
    #abl_1, abl_2, abl_3 = 0, 0 ,0
    for j in range (len(a)):
        mask = 1 << j
        if i & mask:
            cost += a[j][0]
            for k in range(m):
                abl_sum[k] += a[j][k + 1]
            # abl_1 +=  a[j][1]
            # abl_2 += a[j][2]
            # abl_3 += a[j][3]
    cost_lis.append(cost)
    abl_lis.append(abl_sum)
    #print(bin(i))
print(cost_lis, abl_lis)

cost_new_lis = []
for i in range(len(abl_lis)):
    if min(abl_lis[i]) >= x:
        cost_new_lis.append(cost_lis[i])
    else:
        pass
#print(cost_new_lis)

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ans = 10**6
for i in range(1,2**n):
  l = []
  for j in range(n):
    if (i >> j) & 1:
      l.append(ca[j])
  s = np.sum(l,axis=0).tolist()
  if all(s[k] >= x for k in range(1,m+1)) and s[0] < ans:
    ans = s[0]

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

Submission status: Wrong Answer

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

min_sum_answer = -1
for i in range(n**2):
      min_sum = 0
      get_score = []
      for v in range(m):
         get_score.append(0)   
      for j in range(n):
            if (i >> j) & 1 ==1:
                  min_sum += c_a[j][0]
                  for l in range(m):
                        get_score[l] += c_a[j][l+1]
      
      #print(get_score)
      pre = 0 
      for s in range(m):
            if(get_score[s] < x):
                  pre = 1
                  break
      
      if pre == 0:
            if min_sum_answer == -1:
                  min_sum_answer = min_sum 
            elif min_sum_answer > min_sum:
                  min_sum_answer = min_sum 

if min_sum_answer == 0:
      print(-1)
else:
      print(min_sum_answer)

Submission status: Wrong Answer

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

min_sum_answer = -1
for i in range(n**2):
      min_sum = 0
      get_score = []
      for v in range(m):
         get_score.append(0)   
      for j in range(n):
            if (i >> j) % 2 ==1:
                  min_sum += c_a[j][0]
                  for l in range(m):
                        get_score[l] += c_a[j][l+1]
      
      #print(get_score)
      pre = 0 
      for s in range(m):
            if(get_score[s] < x):
                  pre = 1
                  break
      
      if pre == 0:
            if min_sum_answer == -1:
                  min_sum_answer = min_sum 
            elif min_sum_answer > min_sum:
                  min_sum_answer = min_sum 

if min_sum_answer == 0:
      print(-1)
else:
      print(min_sum_answer)

Submission status: Wrong Answer

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

min_sum_answer = 0
for i in range(n**2):
      min_sum = 0
      get_score = []
      for v in range(m):
         get_score.append(0)   
      for j in range(n):
            if (i >> j) % 2 ==1:
                  min_sum += c_a[j][0]
                  for l in range(m):
                        get_score[l] += c_a[j][l+1]
      
      #print(get_score)
      pre = 0 
      for s in range(m):
            if(get_score[s] < x):
                  pre = 1
                  break
      
      if pre == 0:
            if min_sum_answer == 0:
                  min_sum_answer = min_sum 
            elif min_sum_answer > min_sum:
                  min_sum_answer = min_sum 

if min_sum_answer == 0:
      print(-1)
else:
      print(min_sum_answer)

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
C = []
A = []
for i in range(N):
  c = list(map(int, input().split()))
  C.append(c[0])
  A.append(c[1:])
ans = sum(C)
for n in range(1 << N):
  p = [0 for j in range(M)]
  q = 0
  for i in range(N):
    t = (n >> i) & 1
    q += t * C[i]
    for j in range(M):
      p[j] += t * A[i][j]
  f = 0
  for j in range(M):
    if p[j] < X:
      f = 1
      break
  if f == 0:
    ans = min(ans, q)
if ans == sum(C):
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
C = []
A = []
for i in range(N):
  c = list(map(int, input().split()))
  C.append(c[0])
  A.append(c[1:])
ans = sum(C)
for n in range(2 << N):
  p = [0 for j in range(M)]
  q = 0
  for i in range(N):
    t = (n >> i) & 1
    q += t * C[i]
    for j in range(M):
      p[j] += t * A[i][j]
  f = 0
  for j in range(M):
    if p[j] < X:
      f = 1
      break
  if f == 0:
    ans = min(ans, q)
if ans == sum(C):
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
#bit全探索で選択する本を決定
#templistに各要素×0/1を加えていく
#templistをanslistに加える
#終わったらanslistの要素を上から見ていく
#全スキルが閾値以上で現時点の最安が-1or最安より安いなら最安を上書き
#最安を出力

a = [int(s) for s in input().split()]
N = a[0]
bks = a[1]
bd = a[2]
s = [input().split() for i in range(N)]
anslist = []
for i in range(2**N):
  templist = []
  for t in range(bks+1):
    templist.append(int(0))
  for j in range(N):
    if (i >> j) & 1 == 1:
      for k in range(bks + 1):
        templist[k] += int(s[j][k])
  anslist.append(templist)

ans = int(-1)
for i in range(2**N):
  for j in range(1, bks+1):
    if anslist[i][j] < bd:
      break
    else:
      pass
    if anslist[i][0] < ans or ans == -1:
      ans = anslist[i][0]

print(ans)

Submission status: Wrong Answer

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


cost_max = 12 * (10 ** 5)
book_list = []
flag = 0
for i in range(2**n):
    book_num = 0
    book_list = []
    if i == 0:
        continue
    for j in range(n):
        if (i >> j) & 1:
            book_list.append(ca[j])
            book_num += 1
    for j in range(m):
        skill_revel = 0
        for k in range(book_num):
            skill_revel += book_list[k][j+1]
        if skill_revel >= x:
            if j == (m-1) and k == (book_num-1):
                cost = 0
                for l in range(book_num):
                    cost += book_list[l][0]
                if cost < cost_max:
                    flag = 1 
                    cost_max = cost
            continue
        else:
            break

if flag == 0:
    print(-1)
else:
    print(cost_max)

Submission status: Wrong Answer

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


cost_max = 12 * (10 ** 5)
book_list = []
for i in range(2**n):
    book_num = 0
    book_list = []
    if i == 0:
        continue
    for j in range(n):
        if (i >> j) & 1:
            book_list.append(ca[j])
            book_num += 1
    for j in range(m):
        skill_revel = 0
        for k in range(book_num):
            skill_revel += book_list[k][j+1]
        if skill_revel >= x:
            if j == (m-1) and k == (book_num-1):
                cost = 0
                for l in range(book_num):
                    cost += book_list[l][0]
                if cost < cost_max:
                    cost_max = cost
            continue
        else:
            break

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

Submission status: Wrong Answer

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


cost_max = 12 * (10 ** 5)
book_list = []
for i in range(2**n):
    book_num = 0
    book_list = []
    if i == 0:
        continue
    for j in range(n):
        if (i >> j) & 1:
            book_list.append(ca[j])
            book_num += 1
    for j in range(m):
        skill_revel = 0
        for k in range(book_num):
            skill_revel += book_list[k][j+1]
        if skill_revel >= x:
            if j == (m-1) and k == (book_num-1):
                cost = 0
                for l in range(book_num):
                    cost += book_list[l][0]
                if cost < cost_max:
                    cost_max = cost
            continue
        else:
            break

print(cost_max)

Submission status: Wrong Answer

Solution code:
#C
import numpy as np
from itertools import combinations
N, M, X=map(int,input().split())
C = []
for i in range(N):
    C.append(list(map(int,input().split())))
Comb=[]
for i in range(N):
    Comb+=combinations(C,i)
Sum=[]
for i in range(1,len(Comb)):
    Sum_i=np.sum(np.array(Comb[i]),axis=0)
    if all([i >= X for i in Sum_i[1:]]):
        Sum.append(Sum_i[0])
if len(Sum)==0:
    print(-1)
else:
    print(sorted(Sum)[0])

Submission status: Wrong Answer

Solution code:
from itertools import combinations
import sys

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

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

for i in range(1, n+1):
  cmb = [s for s in combinations(a, i)]
  result = []
  for j in cmb:
    total = [0] * (m+1)
    for s in range(i):
      total = [x+y for (x,y) in zip(j[s], total)]
      result.append(total)
  result.sort()
  for k in result:
    price = k[0]
    del k[0]
    if min(k) >= x:
      print(price)
      sys.exit()

print('-1')

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

for i in range(M):
    if np.sum(A, axis=0)[i] < X:
        print(-1)
        exit()

min_c = 999999999999999
for i in range(2**N):
    item = []
    tmp_c = 0
    for j in range(N):
        if ((i >> j) & 1):
            item.append(A[j])
            tmp_c += C[j]
    if len(item) == 0:
        continue
    for j in range(M):
        if np.sum(item, axis=0)[j] < X:
            break
        if j == len(item)-1:
            if min_c > tmp_c:
                min_c = tmp_c

print(min_c)

Submission status: Wrong Answer

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

ans=float('inf')
for paint_h in range(2**N):
	temp_arr=[0]*M
	for i in range(N):
		if (paint_h>>i)&1==1:
			temp_arr=[a+b for (a, b) in zip(temp_arr, arr[i])]
	if all(i>=X for i in temp_arr[1:]):
		ans=min(ans, temp_arr[0])
print(ans if ans != float('inf') else -1)

Submission status: Wrong Answer

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

ans=1e+15
for paint_h in range(2**N):
	temp_arr=[0]*M
	for i in range(N):
		if (paint_h>>i)&1==1:
			temp_arr=[a+b for (a, b) in zip(temp_arr, arr[i])]
	if all(i>=X for i in temp_arr[1:]):
		ans=min(ans, temp_arr[0])
if ans==1e+15:
	ans=-1
print(ans)

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
Ca = [list(map(int, input().split())) for _ in range(N)]
pattern = []
for i in range(2**N):
    lis = []
    for j in range(N):
        if ((i>>j)&1):
            lis.append(Ca[j])
    pattern.append(lis)

cnt = []
for i in range(2**N):
    g = [0] * (M+1)
    for j in range(len(pattern[i])):
        for k in range(M+1):
            g[k] += pattern[i][j][k]
    if M==1 and g[1]< X:
        continue
    elif M>1 and min(g[1:M]) < X:
        continue
    else:
        cnt.append(g[0])
if len(cnt) ==0:
    print(-1)
else:
    print(min(cnt))

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
Ca = [list(map(int, input().split())) for _ in range(N)]
pattern = []
for i in range(2**N):
    lis = []
    for j in range(N):
        if ((i>>j)&1):
            lis.append(Ca[j])
    pattern.append(lis)

cnt = []
for i in range(2**N):
    g = [0] * (M+1)
    for j in range(len(pattern[i])):
        for k in range(M+1):
            g[k] += pattern[i][j][k]
    if min(g) < X:
        continue
    else:
        cnt.append(g[0])
if len(cnt) ==0:
    print(-1)
else:
    print(min(cnt))

Submission status: Wrong Answer

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

inf = 10000000000
res = inf
for mask in range(2 ** n):
    can = True
    for alg in range(1, m):
        sum = 0
        for i in range(n):
            if ((mask >> i) & 1) == 1:
                sum += list[i][alg]
        if sum < x:
            can = False
    if can == True:
        total = 0
        for i in range(n):
            if ((mask >> i) & 1) == 1:
                total += list[i][0]
        res = min(res, total)

print(-1 if res == inf else res)

Submission status: Wrong Answer

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

inf = 10000000000
res = inf
for mask in range(2**n):
    can = True
    for alg in range(1, m):
        sum = 0
        for i in range(n):
            if ((mask>>i) & 1) == 1:
                sum += list[i][alg]
        if sum < x:
            can = False
    if can == True:
        total = 0
        for i in range(n):
            if ((mask>>i) & 1) == 1:
                total += list[i][0]
        res = min(res, total)

print(-1 if res == inf else res)

Submission status: Wrong Answer

Solution code:
import copy
#データの入力
N,M,X = (int(x) for x in input().split())
CA = [[0] * (M+1) for k in range(N)]
SUM_A = [0]*(M)
SUM_C = 0

for i in range(N):
  ca = list(map(int, input().split()))
  SUM_C += ca[0]
  for j in range(M+1):
    CA[i][j] = ca[j]
    if j>0:
      SUM_A[j-1] += ca[j] 

CA = sorted(CA, reverse=True)


c = True
#習得できていない場合
for l in range(M):
  SUM_A[l] -= X
  if SUM_A[l] < 0:
    c = False
if c == False:
  print(-1)

#習得できている場合
else:
  for n in range(N):
    sum_a = copy.copy(SUM_A)
    for m in range(M):
      sum_a[m] -= CA[n][m+1]
      if sum_a[m] < 0:
        break
      else:
        if m == M-1:
          SUM_A = copy.copy(sum_a)
          SUM_C -= CA[n][0]
  print(SUM_C)

Submission status: Wrong Answer

Solution code:
import copy
N,M,X = (int(x) for x in input().split())
CA = [[0] * (M+1) for k in range(N)]
SUM_A = [0]*(M)
SUM_C = 0

for i in range(N):
  ca = list(map(int, input().split()))
  SUM_C += ca[0]
  for j in range(M+1):
    CA[i][j] = ca[j]
    if j>0:
      SUM_A[j-1] += ca[j] 

CA = sorted(CA, reverse=True)

c = True

for l in range(M):
  SUM_A[l] -= X
  if SUM_A[l] < 0:
    c = False
if c == False:
  print(-1)
else:
  for m in range(N):
    sum_a = copy.copy(SUM_A)
    for n in range(M):
      sum_a[n] -= CA[m][n+1]
      if sum_a[n] < 0:
        break
      else:
        if n == M-1:
          SUM_A = copy.copy(sum_a)
          SUM_C -= CA[m][0]
  
print(SUM_C)

Submission status: Wrong Answer

Solution code:
import copy
N,M,X = (int(x) for x in input().split())
CA = [[0] * (M+1) for k in range(N)]
SUM_A = [0]*(M)
SUM_C = 0

for i in range(N):
  ca = list(map(int, input().split()))
  SUM_C += ca[0]
  for j in range(M+1):
    CA[i][j] = ca[j]
    if j>0:
      SUM_A[j-1] += ca[j] 

CA = sorted(CA, reverse=True)

c = True

for l in range(M):
  SUM_A[l] -= X
  if SUM_A[l] < 0:
    c = False
if c == False:
  print(-1)
else:
  for m in range(N):
    sum_a = copy.copy(SUM_A)
    for n in range(M):
      sum_a[n] -= CA[m][n+1]
      if sum_a[n] < 0:
        break
      else:
        SUM_A[n] = sum_a[n]
        if n == M-1:
          SUM_C -= CA[m][0]
  print(SUM_C)

Submission status: Wrong Answer

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

ans = 12*(10**5)
for i in range(2**n):
    a = [0] * m
    cs = 0
    for j in range(n):
        if (i >> j) & 1:
            cs += ca[j][0]
            for k in range(1, m+1):
                a[k-1] += ca[j][k]
    flag = True
    for j in range(m):
        if a[j] < x:
            flag = False
            break
    if flag:
        ans = min(ans, cs)
if ans == 12*(10**5):
    ans = -1
print(ans)

Submission status: Wrong Answer

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n,m,x = I()
book = [l() for i in range(n)]
money = []

for i in range(2**n):
    ccc = 0
    bag = [0]*m
    for j in range(n):
        for k in range(m):
            if ((i>>j)&1):
                bag[k] += book[j][k]
    for p in range(1,m):
        if bag[p] >= x:
            ccc += 1
    if ccc == m-1:
        money.append(bag[0])

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

Submission status: Wrong Answer

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n,m,x = I()
book = [l() for i in range(n)]
money = []

for i in range(1,2**n):
    ccc = 0
    bag = [0]*m
    for j in range(n):
        for k in range(m):
            if ((i>>j)&1):
                bag[k] += book[j][k]
    for p in range(1,m):
        if bag[p] >= x:
            ccc += 1
    if ccc == m-1:
        money.append(bag[0])

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

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
BOOKS = [tuple(map(int, input().split())) for _ in range(N)]

INF = 10 ** 6
ans = INF
for selection in range(1 << N):
    price = 0
    values = [0] * M
    for i in range(N):
        if selection & (1 << i):
            x = BOOKS[i]
            price += x[0]
            for j in range(M):
                values[j] += x[j+1]
    if all(v >= X for v in values):
        ans = min(ans, price)

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

Submission status: Wrong Answer

Solution code:
N,M,X=map(int,input().split())
C=[]
A=[]
for _ in range(N):
    c,*a=map(int,input().split())
    C.append(c)
    A.append(a)
    
import itertools

ans=10**6
f=False
for i in range(1,N+1):
    for j in itertools.combinations(range(N), i):
        t=[0]*M
        c=0
        
        for k in j:
            c+=C[k]
            t=[t+a for (t,a) in zip(t,A[k])]
        #print(c,t)
        if M <= len([x for x in t if x>=X]):
            ans=min(ans,c)
            f=True
print(ans if f else -1)

Submission status: Wrong Answer

Solution code:
import math
N,M,X = map(int,input().split())
#a[i][0]:price of the i-th book
a = [[] for i in range(N)]
for i in range(N):
    a[i] = list(map(int,input().split()))
a.sort()
#dp[j][k]:lowest amount of money needed to make j-th algorithm level k
dp = [[math.inf for k in range(X+1)] for j in range(M)]
#print(dp)

for j in range(M):
    dp[j][0] = 0

for i in range(N):
    for j in range(M):
        for k in range(X,a[i][j+1],-1):
            dp[j][k] = min(dp[j][k],dp[j][k-a[i][j+1]] + a[i][0])
        for k in range(1,min(a[i][j+1]+1,X+1)):
            dp[j][k] = min(dp[j][k],a[i][0])

#print(dp)
maximum = 0
for j in range(M):
    maximum = max(maximum,dp[j][X])
if maximum == math.inf:
    print(-1)
else:
    print(maximum)

Submission status: Wrong Answer

Solution code:
import numpy
N,M,X = map(int,input().split())
A = numpy.array([[int(i) for i in input().split()] for _ in range(N)])
ans = 10**6
for i in range(2**N) :
    i = format(i,'b').zfill(N)
    s = 0
    check = numpy.array([0]*(M+1))
    for j in range(N) :
        if i[j] == '0' :
            continue
        check +=  A[j][0:]
    if all (check[m] >= X for m in range(1,M+1)) :
        ans = min(ans,check[0])

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

Submission status: Wrong Answer

Solution code:
import numpy
N,M,X = map(int,input().split())
A = numpy.array([[int(i) for i in input().split()] for _ in range(N)])
ans = 10**6
for i in range(2**N) :
    i = format(i,'b').zfill(N)
    s = 0
    check = numpy.array([0]*(M+1))
    for j in range(N) :
        if i[j] == '0' :
            continue
        check +=  A[j][0:]
#        print('i = {},j = {},check = {}'.format(i,j,check))
    if all (check[m] >= X for m in range(1,M)) :
        ans = min(ans,check[0])

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

Submission status: Wrong Answer

Solution code:
import numpy
N,M,X = map(int,input().split())
A = numpy.array([[int(i) for i in input().split()] for _ in range(N)])
ans = 10**6
for i in range(2**N) :
    i = format(i,'b').zfill(N)
    s = 0
    check = numpy.array([0]*(M+1))
    for j in range(N) :
        if i[j] == '0' :
            continue
        check +=  A[j][0:]
#        print('i = {},j = {},check = {}'.format(i,j,check))
    if all (check[m] >= X for m in range(1,M)) :
        ans = min(ans,check[0])

print(ans)

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
C=[]
A=[]
for _ in range(N):
    c, *a = map(int, input().split())
    C.append(c)
    A.append(a)

ans=10**5*N
for maskN in range(1<<N):
  cost=0
  level=[0]*M
  for n in range(N):
    if (maskN>>n&1):
      cost+=C[n]
      for m in range(M):
        level[m] += A[n][m]
  for l in level:
    if l < X:
      break
  else:
    ans=min(ans, cost)
print(f'{ans if ans!=10**5*N else "-1"}')

Submission status: Wrong Answer

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


ans=10**5*N
for maskN in range(1<<N):
  cost=0
  level=[0]*M
  for n in range(N):
    if (maskN>>n&1):
      cost+=S[n][0]
      for m in range(M):
        level[m] += S[n][m+1]
  for l in level:
    if l < X:
      break
  else:
    ans=min(ans, cost)
print(f'{ans if ans!=10**5*N else "-1"}')

Submission status: Wrong Answer

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

ans=inf=float('inf')
for p in range(1<<N):
    tt,lvls=0,[0]*M
    for i in range(N):
        if p&i==0:
            continue
        tt+=C[i][0]
        for j in range(M):
            lvls[j]+=C[i][j+1]
        for j in range(M):
            if lvls[j]<X:
                break
        else:
            ans=min(ans,tt)
            break


print(ans if ans<inf else -1)

Submission status: Wrong Answer

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

ans=inf=float('inf')
def dfs(idx,tt,l):
    global ans
    for i in range(idx,N):
        ntt=tt+C[i][0]
        nl=[l[j]+C[i][j+1] for j in range(M)]
        ok=False
        for x in nl:
            if x<X:
              ok=True
              break
        if ok:
            ans=min(ans,ntt)
        else:
	        dfs(i+1,ntt,nl)
        
dfs(0,0,[0]*M)

print(ans if ans<inf else -1)

Submission status: Wrong Answer

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

ans = 10 ** 18

for i in range(1 << n): #全パターン
    cost = 0
    total = [0] * m #値段とm冊の本についてのリスト
    for j in range(n):
        if (i>>j) & 1 == 1 : #iをjだけ右にシフト。j冊目を買う場合
            cost += ca[j][0]
            for k in range(m):
                total[k] += ca[j][k+1]
    for l in range(m): #各理解度がxを上回るかチェックする
        if total[l] < x:
            break
        else:
            ans = min(ans, cost)

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

Submission status: Wrong Answer

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

ans = 10 ** 6

for i in range(1 << n): #全パターン
    cost = 0
    total = [0] * m #値段とm冊の本についてのリスト
    for j in range(n):
        if (i>>j) & 1 == 1 : #iをjだけ右にシフト。j冊目を買う場合
            cost += ca[j][0]
            for k in range(m):
                total[k] += ca[j][k+1]
    for l in range(m): #各理解度がxを上回るかチェックする
        if total[l] < x:
            break
        else:
            ans = min(ans, cost)

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

Submission status: Wrong Answer

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

ans = 10 ** 6

for i in range(1 << n): #全パターン
    total = [0] * (m+1) #値段とm冊の本についてのリスト
    for j in range(n):
        if (i>>j) & 1 == 1 : #iをjだけ右にシフト。j冊目を買う場合
            for k in range(m+1):
                total[k] += ca[j][k]
    for l in range(1,m+1): #各理解度がxを上回るかチェックする
        if total[l] < x:
            break
        else:
            ans = min(ans, total[0])

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

Submission status: Wrong Answer

Solution code:
N,M,X=map(int,input().split())
B=[list(map(int,input().split())) for _ in range(N)]
ans=(10**5)*12+1
for i in range(1,2**N):
  tmp=[0]*M
  c=0
  for j in range(N):
    if i>>j&1:
      for k in range(M):
        tmp[k]+=B[j][k+1]
      c+=B[j][0]
  if len([i for i in tmp if i>=X])==M:
    ans=min(c,ans)
print(ans)

Submission status: Wrong Answer

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

A=[0]*N
for j in range(N):
    A[j]=[int(x) for x in input().split()]
money=10**7
for i in range(2**N):
    read=[0]*N #その本を読むか否か
    for h in range(N):
        if i%2==1:
            read[h]=1
        i//=2
    understanding=[0]*M
    kouho=0
    for k in range(N):
        if read[k]==1:
            kouho+=A[k][0]
            for m in range(1,M+1):
                understanding[m-1]+=A[k][m-1]
    if min(understanding)>=X:
        money=min(money,kouho)
if money==10**7:
    print(-1)
else:
    print(money)

Submission status: Wrong Answer

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

# 参考書の組み合わせ
price_min = pow(10, 5) * n
found = False
for bits in range(2 ** n):
    level = [0] * m
    price = 0
    # ビットが立っている参考書の理解度と値段を加算
    for book in range(n):
        if (bits >> book) & 1:
            price += books[book][0]
            for alg in range(m):
                level[alg] += books[book][alg + 1]
    # 理解度がXに満たないアルゴリズムを抽出
    level = list(filter(lambda lv: lv < x, level))
    # 理解度の条件を満たし、かつ合計額が最低値を下回るときに最低値を更新
    if len(level) == 0 and price < price_min:
        price_min = price
        found = True
print(price_min if found else "-1")

Submission status: Wrong Answer

Solution code:
# a bruty bitch
a,b,c = map(int,input().split())
cuc,sus, ans = [],[0]*b,0
for _ in range(a):
    cuc.append(list(map(int,input().split())))
    ans += cuc[-1][0]
    for x in range(b):
        sus[x]+=cuc[-1][x+1]
cuc.sort( reverse = True )
if any(j < c for j in sus): print(-1)
else:
    for ct in cuc:
        flag = 1
        for x in range(b):
            if sus[x] - ct[x+1] < c: flag = 0; break
        if flag:
            ans -= ct[0]
            for x in range(b):
                sus[x]-=ct[x+1]
    print(ans)

Submission status: Wrong Answer

Solution code:
# a bruty bitch
a,b,c = map(int,input().split())
cuc,sus, ans = [],[0]*b,0
for _ in range(a):
    cuc.append(list(map(int,input().split())))
    ans += cuc[-1][0]
    for x in range(b):
        sus[x]+=cuc[-1][x+1]
cuc.sort( reverse = True, key = lambda x: x[0] )
if any(j < c for j in sus): print(-1)
else:
    for ct in cuc:
        flag = 1
        for x in range(b):
            if sus[x] - ct[x+1] < c: flag = 0; break
        if flag:
            ans -= ct[0]
            for x in range(b):
                sus[x]-=ct[x+1]
    print(ans)