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:
from sys import maxsize
import numpy as np


def check(ls, x):
    for i in range(1, len(ls)):
        if ls[i] < x:
            return False
    return True


def convert(b, n):
    diff = n - len(b)
    return ('0' * diff + b)[::-1]


n, m, x = map(int, input().split())
ls = []
a = [i for i in range(n)]
for i in range(n):
    ls.append(list(map(int, input().split())))
dp = [0] * ((1 << n) + 1)
for i in range(n):
    dp[1 << i] = np.array(ls[i])
total_cost = maxsize
for subset in range(1, (1 << n)):
    b = bin(subset)[2:]
    b = convert(b, n)
    a = np.zeros(m + 1)
    for i in range(n):
        if int(b[i]):
            a += dp[1 << i]
    dp[subset] = a
    if check(dp[subset], x):
        total_cost = min(total_cost, dp[subset][0])
print(int(total_cost))

Submission status: Wrong Answer

Solution code:
import numpy as np
from itertools import combinations_with_replacement

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

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

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

Submission status: Wrong Answer

Solution code:
if __name__=="__main__":
    N, M, X = map(int, input().split(' '))
    book_list = [None]*N
    min_price = -1
    for i in range(N):
        book_list[i] = list(map(int, input().split(' ')))

    for i in range(2 ** N):
        comp_list = []
        for j in range(N):
            if ((i >> j) & 1):
                if comp_list == []:
                    comp_list = book_list[j]
                else:
                    comp_list = [a + b for a, b in zip(comp_list, book_list[j])]

                if all(comp >= X for comp in comp_list):
                    if min_price == -1:
                        pass
                    elif comp_list[0] <= min_price:
                        min_price = comp_list[0]
    print(min_price)

Submission status: Wrong Answer

Solution code:

if __name__=="__main__":
    N, M, X = map(int, input().split(' '))
    book_list = [None]*N
    min_price = -1
    for i in range(N):
        book_list[i] = list(map(int, input().split(' ')))

    for i in range(2 ** N):
        comp_list = []
        for j in range(N):
            if ((i >> j) & 1):
                if comp_list == []:
                    comp_list = book_list[j]
                else:
                    comp_list = [a+b for a, b in zip(comp_list, book_list[j])]

                if all(comp >= X for comp in comp_list):
                    if min_price == -1:
                        min_price = comp_list[0]
                    elif comp_list[0] < min_price:
                        min_price = comp_list[0]
    print(min_price)

Submission status: Wrong Answer

Solution code:
import numpy as np
from itertools import combinations_with_replacement

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

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

if OK == False:
  print(-1)
else:
  As = []
  for A in combinations_with_replacement(range(0, N), r=M):
    As.append(tuple(set(A)))
  As = list(map(list, set(As)))
  last_val = sums[0]
  for ls in As:
    ls = list(set(ls))
    ans = [0] * M
    val = 0
    for a in ls:
      for ix,i in enumerate(CA[a-1][1:]):
        ans[ix] += i
      val += CA[a-1][0]
    b = [i for i in ans if i >= X]
    if len(b) == len(ans):
      last_val = min(last_val, val)
  print(last_val)

Submission status: Wrong Answer

Solution code:
import sys

lines = sys.stdin.readlines()
N, M, X = map(int, lines[0].split())
A = []
C = []

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

# return []
def full_search():
    costs = []
    for i in range(2**N):
        vals = [0] * M
        cost = 0

        # iを二進数に直して扱う。それぞれのビットがn冊目の本を買うかどうかに匹敵。
        for j in range(N):
            # ビットを移動しながらn冊目の本を買う際のコストと経験値を計算する
            if ((i >> j) & 1):
                # 現在の組み合わせに対して
                # 全てのアルゴリズム分を計算
                cost += C[j]

                # 全てのアルゴリズム(m)に対して経験値を求める
                for m in range(M):
                    vals[m] += A[j][m]

        combination_ok = True
        for m in range(M):
            if vals[m] >= X:
                continue
            else:
                combination_ok = False
                break

        if combination_ok:
            costs.append(cost)
    return costs

costs = full_search()
if len(costs) == 0:
    print(-1)
else:
    print(costs[0])

Submission status: Wrong Answer

Solution code:
import math

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


minimum = 10 ** 5 * 12
for i in range(2**N):
    comp = [0] * (M + 1)
    for j in range(N):
        if (i >> j) & 1:
            comp = [x + y for (x, y) in zip(comp, CA[j])]
    flag = True
    for j in range(M + 1):
        if j == 0:
            continue
        if comp[j] < X:
            flag = False
            break
    if minimum > comp[0] and flag:
        minimum = comp[0]

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

Submission status: Wrong Answer

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

ans = float('inf')
def dfs(step, m_list, cost):
    global ans
    if all(elem>=x for elem in m_list):
        ans = min(cost, ans)
    elif step != n:
        dfs(step+1, m_list, cost)
        m_list = [x+y for x, y in zip(m_list, a[step][0:])]
        cost += a[step][0]
        dfs(step+1, m_list, cost)

dfs(0, [0]*m, 0)
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():#IO
    N,M,X=pin()
    #C,A
    BooKs=[]
    Costs=[]
    for i in range(N):
        #C, A_i_1..A_i_M->C,[A_i_*]
        c,*A=pin()
        BooKs.append(A)
        Costs.append(c)

    #bit full search
    ans=sum(Costs)
    flag2 = 0#if false,skillを満たす本の集まりが存在しません
    for i in (range(1<<N)):
        #initialize
        currentcost=0
        flag=1
        currentskill=[0]*(M)
        #bit check
        for j in range(N):
            if i&(1<<j):
                #print(j,"j")
                currentcost+=Costs[j]
            ##print(currentcost,"cst")
            #renew currentskill
                for k in range(M):
                    currentskill[k]+=BooKs[j][k]
        #skill check
        ##print(currentskill)
        for m in range(M):
            if currentskill[m]<X:flag=0
        if flag: flag2=1;ans=min(ans,currentcost)
        #print(ans)
    #output    
    a=ans if flag2 else -1
    print(a)

Submission status: Wrong Answer

Solution code:
if __name__=="__main__":
    N, M, X = map(int, input().split(' '))
    book_list = [None]*N
    min_price = -1
    for i in range(N):
        book_list[i] = list(map(int, input().split(' ')))

    for i in range(2 ** N):
        comp_list = []
        for j in range(N):
            if ((i >> j) & 1):
                if comp_list == []:
                    comp_list = book_list[j]
                else:
                    comp_list = [a+b for a, b in zip(comp_list, book_list[j])]
                print(comp_list)
                if all(comp >= X for comp in comp_list):
                    if min_price == -1:
                        min_price = comp_list[0]
                    elif comp_list[0] < min_price:
                        min_price = comp_list[0]
    print(min_price)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

def function(CA, n, total, skill, C, X_l):
  CAn = CA[n]
  An = CAn[1:]
  skill = np.array(skill) + np.array(An)
  skill = list(skill)
  total += CAn[0]
  if skill >= X_l:
    C.append(total)
  return total, skill, C

C = []
X_l = [X]*M

count = 0
for a in range(N):
  total = 0
  skill = [0]*M
  total_a, skill_a, C = function(CA, a, total, skill, C, X_l)
  for b in range(a+1, N):
    total_b, skill_b, C = function(CA, b, total_a, skill_a, C, X_l)
    for c in range(b+1, N):
      total_c, skill_c, C = function(CA, c, total_b, skill_b, C, X_l)
      for d in range(c+1, N):
        total_d, skill_d, C = function(CA, d, total_c, skill_c, C, X_l)
        for e in range(d+1, N):
          total_e, skill_e, C = function(CA, e, total_d, skill_d, C, X_l)
          for f in range(e+1, N):
            total_f, skill_f, C = function(CA, f, total_e, skill_e, C, X_l)
            for g in range(f+1, N):
              total_g, skill_g, C = function(CA, g, total_f, skill_f, C, X_l)
              for h in range(g+1, N):
                total_h, skill_h, C = function(CA, h, total_g, skill_g, C, X_l)
                for i in range(h+1, N):
                  total_i, skill_i, C = function(CA, i, total_h, skill_h, C, X_l)
                  for j in range(i+1, N):
                    total_j, skill_j, C = function(CA, j, total_i, skill_i, C, X_l)
                    for k in range(j+1, N):
                      total_k, skill_k, C = function(CA, k, total_j, skill_j, C, X_l)
                      for l in range(k+1, N):
                        total_l, skill_l, C = function(CA, l, total_k, skill_k, C, X_l)

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

Submission status: Wrong Answer

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

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

np_CA = np.array(CA)

min_val = 1001001001
flag = False
for i in range(2 ** N):
    stacks = np.zeros(M + 1)
    for j in range(N):
        if ((i >> j) & 1):
            stacks += np_CA[j]
            
    skills = stacks[0:]
    if all(skills >= X ) and min_val > stacks[0]:
        min_val = stacks[0]
        flag = True

if flag == False:
    print("-1")

else:
    print(int(min_val))

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
ans = 10**9
for bi in range(int("1"*n,2)):
    l = [0]*m
    p = 0
    for k,si in enumerate(str(format(bi,f"0{n}b"))):
        if si=="1":
            b = a[k]
            for j,i in enumerate(b[1:]):
                l[j]+=i
            p+=b[0]
    if all([i>=x for i in l]):
        ans=min(ans,p)
if ans==10**9:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

def function(CA, n, total, skill, C, X_l):
  CAn = CA[n]
  An = CAn[1:]
  skill = np.array(skill) + np.array(An)
  skill = list(skill)
  total += CAn[0]
  if skill >= X_l:
    C.append(total)
  return total, skill, C

C = []
X_l = [X]*M

count = 0
for a in range(N):
  total = 0
  skill = [0]*M
  total_a, skill_a, C = function(CA, a, total, skill, C, X_l)
  for b in range(a+1, N):
    total_b, skill_b, C = function(CA, b, total_a, skill_a, C, X_l)
    for c in range(b+1, N):
      total_c, skill_c, C = function(CA, c, total_b, skill_b, C, X_l)
      for d in range(c+1, N):
        total_d, skill_d, C = function(CA, d, total_c, skill_c, C, X_l)
        for e in range(d+1, N):
          total_e, skill_e, C = function(CA, e, total_d, skill_d, C, X_l)
          for f in range(e+1, N):
            total_f, skill_f, C = function(CA, f, total_e, skill_e, C, X_l)
            for g in range(f+1, N):
              total_g, skill_g, C = function(CA, g, total_f, skill_f, C, X_l)
              for h in range(g+1, N):
                total_h, skill_h, C = function(CA, h, total_g, skill_g, C, X_l)
                for i in range(h+1, N):
                  total_i, skill_i, C = function(CA, i, total_h, skill_h, C, X_l)
                  for j in range(i+1, N):
                    total_j, skill_j, C = function(CA, j, total_i, skill_i, C, X_l)
                    for k in range(j+1, N):
                      total_k, skill_k, C = function(CA, k, total_j, skill_j, C, X_l)
                      for l in range(k+1, N):
                        total_l, skill_l, C = function(CA, l, total_k, skill_k, C, X_l)

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

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
ans = 10**6
for bi in range(int("1"*n,2)):
    l = [0]*m
    p = 0
    for k,si in enumerate(str(format(bi,f"0{n}b"))):
        if si=="1":
            b = a[k]
            for j,i in enumerate(b[1:]):
                l[j]+=i
            p+=b[0]
    if all([i>=x for i in l]):
        ans=min(ans,p)
print(ans)

Submission status: Wrong Answer

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

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

np_CA = np.array(CA)

min_val = 1001001001
flag = False
for i in range(2 ** N):
    stacks = np.zeros(M + 1)
    for j in range(N):
        if ((i >> j) & 1):
            stacks += np_CA[j]
            
    skills = stacks[0:]
    if skills.min() >= X and min_val > stacks[0]:
        min_val = stacks[0]
        flag = True

if flag == False:
    print("-1")

else:
    print(int(min_val))

Submission status: Wrong Answer

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

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

np_CA = np.array(CA)

min_val = 1e+10
flag = False
for i in range(2 ** N):
    stacks = np.zeros(M + 1)
    for j in range(N):
        if ((i >> j) & 1):
            stacks += np_CA[j]
            
    skills = stacks[0:]
    if skills.min() >= X and min_val > stacks[0]:
        min_val = stacks[0]
        flag = True

if flag == False:
    print("-1")

else:
    print(int(min_val))

Submission status: Wrong Answer

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

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

np_CA = np.array(CA)

min_val = 1e+5
flag = False
for i in range(2 ** N):
    stacks = np.zeros(M + 1)
    for j in range(N):
        if ((i >> j) & 1):
            stacks += np_CA[j]

    if stacks[0:].min() >= X and min_val > stacks[0]:
        min_val = stacks[0]
        flag = True

if flag == False:
    print("-1")

else:
    print(int(min_val))

Submission status: Wrong Answer

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

for i in range(2**n):
    sum = [0]*(m+1)
    # n桁について調査
    for j in range(n):
        # iのj桁目が1かどうかcheck
        if ((i >> j) & 1):
            for k in range(m+1):
                sum[k] += l[j][k]
    if sum[0] < ans:
        for a in range(1,m+1):
            if sum[a] < x:
                break
            else:
                ans = sum[0]
if ans == float('inf'):
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
N,M,X=map(int,input().split())
l=[]
for i in range (N):
  l.append(list(map(int,input().split())))
ans=10000000
for i in range(2**N):
  score=[0]*M
  coin=0
  for j in range(N):
    if i>=2**(N-1-j):
      for p in range(M):
        score[p]+=l[j][p+1]
      coin+=l[j][0]
      i-=2**(N-1-j)
  flag=0
  for q in range(M):
    if score[q]<X:
      flag=1
  if flag==0:
    if ans>coin:
      ans=coin
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
n,m,x = map(int,input().split())
c=[]
for i in range(n):
  c.append(list(map(int,input().split())))
#print(c)

ans = 9999999999

for el in itertools.product([0,1],repeat=n):
  # 達成可能性の判定
  cav = [0]*(m+1)
  for i in range(n):
    if el[i] == 1:
      for j in range(m+1):
        cav[j] += c[i][j]

  if x > min(cav[1:m+1]):
    pass
  else:
    ans = min(cav[0],ans)

print(ans)

Submission status: Wrong Answer

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

a = [[int(i) for i in input().split()] for _ in range(n)] #行列
#s = [int(input()) for _ in range()] #縦
#a = [int(x) for x in input().split()] #横

sum1 = [0] * (m+1)
sum2 = [0] * (m+1)

ans = 0

st = list(itertools.product([0,1], repeat = n))
#print(st)

for i in range(n):
    for j in range(m+1):
        sum1[j] += a[i][j]
for  i in range(1,m+1):
    if sum1[i] < x:
        sum1[0] = -1
        print(-1)
        exit()

ans = sum1[0]

for i in range(2**n):
    for j in range(n):
        for k in range(m):
            #print(i,j,k)
            sum2[k] +=  a[j][k]*st[i][j]
    #print(sum2[0])
    for i in range(1,m):
        if sum2[i]  < x:
            sum2[0]= 100000000
    ans = min(sum2[0],ans)
    #print(ans)
    sum2 = [0] * (m+1)

print(ans)

Submission status: Wrong Answer

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

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

np_CA = np.array(CA)

min_val = 1e+5
flag = False
for i in range(2 ** N):
    stacks = np.zeros(M + 1)
    for j in range(N):
        if ((i >> j) & 1):
            stacks += np_CA[j]

    if stacks[1:].min() >= X and min_val > stacks[0]:
        min_val = stacks[0]
        flag = True

if flag == False:
    print("-1")

else:
    print(int(min_val))

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
c=[0]*n
a=[0]*n
ans=10**10
for i in range(n):
  d,*b=map(int,input().split())
  c[i]=d
  a[i]=b
import numpy as np
a=np.array(a)
from itertools import product
r=list(product([0,1],repeat=n))
for i in r:
  tmp=np.array([0]*m)
  cost=0
  for j,k in enumerate(i):
    tmp+=k*a[j]
    cost+=k*c[j]
  if all(tmp>=x):
    ans=min(ans,cost)
print(ans)

Submission status: Wrong Answer

Solution code:
N , M ,X = map(int,input().split())
 
L = []
for i in range(N):
  temp = list(map(int,input().split()))
  L.append(temp)
  
INF = float('inf')
ans = INF
 
for i in range(1,2**N-1):
  skill = [0 for i in range(M)]
  b = 0
  for j in range(N):
    if(i>>j)&1==1:
      b += L[j][0]
      for t in range(M):
        skill[t] += L[j][t+1]
  if all([skill[y] >= X for y in range(M)]):
    #print(skill)
    ans = min(ans,b)

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

Submission status: Wrong Answer

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

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

np_CA = np.array(CA)

min_val = 1e+5
flag = False
for i in range(2 ** N):
    stacks = np.zeros(M + 1)
    for j in range(N):
        if ((i >> j) & 1):
            stacks += np_CA[j]

    if stacks[1:].min() >= X and min_val > stacks[0]:
        min_val = stacks[0]
        flag = True

if flag == False:
    print(-1)

else:
    print(int(min_val))

Submission status: Wrong Answer

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

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

np_CA = np.array(CA)

min_val = 1e+5

for i in range(2 ** N):
    stacks = np.zeros(M + 1)
    for j in range(N):
        if ((i >> j) & 1):
            stacks += np_CA[j]

    if stacks[1:].min() >= X and min_val > stacks[0]:
        min_val = stacks[0]

if min_val == 1e+5:
    print(-1)

else:
    print(int(min_val))

Submission status: Wrong Answer

Solution code:
# coding:utf-8
# bit全探索
n, m, x = map(int, input().split())
book = [list(map(int, input().split())) for _ in range(n)]
ans = 12 * (10 ** 5) + 1

for bit in range(2 ** n):
    tmp_book = [0] * m
    price = 0
    for i in range(n):
        if ((bit >> i) & 1):
            price += book[i][0]
            for j in range(m):
                tmp_book[j] += book[i][j]
    if all(item >= x for item in tmp_book):
        ans = min(price, ans)

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

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
a_list = []
for i in range(n):
    a_list.append(list(map(int, input().split())))
a_list = sorted(a_list, reverse=True, key=lambda x: x[0])

def skill():
    sum_list = [0] * (m + 1)
    for i in range(n):
        sum_list = [x + y for (x, y) in zip(sum_list, a_list[i])]

    return sum_list
print(skill())

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
dp = [[[130000000 for i in range(x+1)]for j in range(m)]for k in range(n)]
check = [0]*m
a0 = list(map(int,input().split()))

for j in range(m):
    check[j] += a0[j+1]
    for k in range(x+1):
        if k <= a0[j+1]:
          dp[0][j][k] = a0[0]
        dp[0][j][0] = 0
for i in range(1,n):
    a = list(map(int,input().split()))
    for j in range(m):
        dp[i][j][0] = 0
        check[j] += a[j+1]
        for k in range(x+1):
             dp[i][j][k] = min(dp[i-1][j][k],dp[i-1][j][max(k-a[j+1],0)]+a[0])

able = True
max = 0
for i in range(m):
    if check[i] < x:
        able = False
    if dp[n-1][i][x] != 130000000 and dp[n-1][i][x] > max:
        max = dp[n-1][i][x]

if able:
    print(max)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
from math import sqrt

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

books=[]
for i in range(n):
    arr = list(map(int,input().split()))
    books.append(arr)
tot_sum=0
ratings=[0]*m
for i in range(n):
    for j in range(m):
        ratings[j]+=books[i][j+1]
flag=True
for i in ratings:
    if(i<x):
        flag=False
        break
if(flag==False):
    print(-1)
else:
    for i in books:
        tot_sum+=i[0]
    books.sort(reverse=True)
    for i in books:
        deletable=True
        for j in range(m):
            if(ratings[j]-i[j+1]<x):
                deletable=False
                break
        if(deletable):
            for j in range(m):
                ratings[j] -= i[j+1]
            tot_sum-=i[0]
    print(tot_sum)

Submission status: Wrong Answer

Solution code:
import numpy as np

N,M,X = map(int,input().split())
arr = [np.array(list(map(int,input().split()))) for _ in range(N)]
ans = float('inf')
for i in range(2**N):
  arr_sum = np.array([0]*(M+1))
  for j in range(N):
    if i>>j&1:
      arr_sum += arr[j]
  if np.all(arr_sum[1:]>=X):
    ans = min(ans,arr_sum[0])
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

def function(CA, n, total, skill, C, X_l):
  CAn = CA[n]
  An = CAn[1:]
  skill = np.array(skill) + np.array(An)
  skill = skill.tolist()
  total += CAn[0]
  if skill >= X_l:
    C.append(total)
  return total, skill, C

C = []
X_l = [X]*M

for a in range(N):
  total = 0
  skill = [0]*M
  total_a, skill_a, C = function(CA, a, total, skill, C, X_l)
  for b in range(a+1, N):
    total_b, skill_b, C = function(CA, b, total_a, skill_a, C, X_l)
    for c in range(b+1, N):
      total_c, skill_c, C = function(CA, c, total_b, skill_b, C, X_l)
      for d in range(c+1, N):
        total_d, skill_d, C = function(CA, d, total_c, skill_c, C, X_l)
        for e in range(d+1, N):
          total_e, skill_e, C = function(CA, e, total_d, skill_d, C, X_l)
          for f in range(e+1, N):
            total_f, skill_f, C = function(CA, f, total_e, skill_e, C, X_l)
            for g in range(f+1, N):
              total_g, skill_g, C = function(CA, g, total_f, skill_f, C, X_l)
              for h in range(g+1, N):
                total_h, skill_h, C = function(CA, h, total_g, skill_g, C, X_l)
                for i in range(h+1, N):
                  total_i, skill_i, C = function(CA, i, total_h, skill_h, C, X_l)
                  for j in range(i+1, N):
                    total_j, skill_j, C = function(CA, j, total_i, skill_i, C, X_l)
                    for k in range(j+1, N):
                      total_k, skill_k, C = function(CA, k, total_j, skill_j, C, X_l)
                      for l in range(k+1, N):
                        total_l, skill_l, C = function(CA, l, total_k, skill_k, C, X_l)

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

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(n)]
c = [ca[i][0] for i in range(n)]
a = [ca[i][1:] for i in range(n)]
l = 0
for i in range(2 ** n):
    ans = 0
    get = [0] * m
    kari = 0
    for j in range(n):
        if (i >> j) & 1:
            get = [x + y for (x, y) in zip(get, a[j])]
            kari += c[j]
    if all([z >= x for z in get]):
        ans = min(ans,kari)
        l += 1
if l == 0:
    ans = -1

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools

Cmin = 10**10
N, M, X = map(int, input().split())
L = np.array([[int(j) for j in input().split()] for i in range(N)])
for i in range(N):
  for idx in itertools.combinations(list(range(N)), i+1):
    A = np.zeros(M+1, dtype=int)
    for j in idx:
      A = A + L[j]
    print(A)
    if A[0] < Cmin and (A[1:] >= X).all() == True:
      Cmin = A[0]
if Cmin == 10**10:
  print(-1)
  exit()
print(Cmin)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import itertools
import sys

N, M, X  = map(int, input().split())
money = []
A = []
ans = []
for _ in range(N):
    nums = [int(x.strip()) for x in input().split(' ') ]
    money.append(nums[0])
    nums.pop(0)
    A.append(nums)

    
def run(lis, num, A, X, M, ans):
    ans_list = []
    for team in itertools.combinations(lis, num):
        count = 0
        for i in range(M):
            tmp = 0
            for j in list(team):
                tmp += A[lis.index(j)][i]
            if tmp >= X:
                count += 1
        if count == M:
            ans_list.append(sum(list(team)))
    if not len(ans_list) == 0:
        ans.append(min(ans_list))
    
    return ans
        
for i in range(0, N+1):
    ans = run(money, i, A, X, M, ans)
    
if not len(ans) == 0:
    print(min(ans))
    
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n, m, x = [int(x) for x in input().split()]
c = []
a = []
for i in range(n):
  tmp = [int(x) for x in input().split()]
  c.append(tmp[0])
  a.append(tmp[1:])
#全探索
ans = 10**8 # as INF
for s in range(2**n):
  cost = 0
  d = [0 for j in range(m)]
  for i in range(n):
    is_use = bin(s>>i&1) == bin(1)
    if is_use:
      cost += c[i]
      for j in range(m):
        d[j]+=a[i][j]
  ok = True
  for j in range(m):
    if d[j] < x:
      ok = False
  if ok and cost < ans:
    ans = cost
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import itertools
import sys

N, M, X  = map(int, input().split())
money = []
A = []
ans = []
for _ in range(N):
    nums = [int(x.strip()) for x in input().split(' ') ]
    money.append(nums[0])
    nums.pop(0)
    A.append(nums)

    
def run(lis, num, A, X, M, ans):
    ans_list = []
    for team in itertools.combinations(lis, num):
        count = 0
        for i in range(M):
            tmp = 0
            for j in list(team):
                tmp += A[lis.index(j)][i]
            if tmp >= X:
                count += 1
        if count == M:
            ans_list.append(sum(list(team)))
    if not len(ans_list) == 0:
        ans.append(min(ans_list))
    
    return ans
        
for i in range(1, N+1):
    ans = run(money, i, A, X, M, ans)
    
if not len(ans) == 0:
    print(min(ans))
    
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
from itertools import combinations_with_replacement

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

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

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import itertools
import sys

N, M, X  = map(int, input().split())
money = []
A = []
ans = []
for _ in range(N):
    nums = [int(x.strip()) for x in input().split(' ') ]
    money.append(nums[0])
    nums.pop(0)
    A.append(nums)

    
def run(lis, num, A, X, M, ans):
    ans_list = []
    for team in itertools.combinations(lis, num):
        count = 0
        for i in range(M):
            tmp = 0
            for j in list(team):
                tmp += A[lis.index(j)][i]
            if tmp >= X:
                count += 1
        if count == M:
            ans_list.append(sum(list(team)))
    if not len(ans_list) == 0:
        ans.append(min(ans_list))
    
    return ans
        
for i in range(1, N+2):
    ans = run(money, i, A, X, M, ans)
    
if not len(ans) == 0:
    print(min(ans))
    
else:
    print(-1)