Problem:


Score : 300 points

Problem

Takahashi, who is a novice in competitive programming, wants to learn M algorithms.
Initially, his understanding level of each of the M algorithms is 0.

Takahashi is visiting a bookstore, where he finds N books on algorithms.
The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M).
There is no other way to increase the understanding levels of the algorithms.

Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Constraints

All values in input are integers.

1\leq N, M\leq 12

1\leq X\leq 10^5

1\leq C_i \leq 10^5

0\leq A_{i, j} \leq 10^5

Input

Input is given from Standard Input in the following format:

N M X
C_1 A_{1,1} A_{1,2} \cdots A_{1,M}
C_2 A_{2,1} A_{2,2} \cdots A_{2,M}
\vdots
C_N A_{N,1} A_{N,2} \cdots A_{N,M}

Output

If the objective is not achievable, print -1; otherwise, print the minimum amount of money needed to achieve it.

Sample Input 1

3 3 10
60 2 2 4
70 8 7 9
50 2 3 9

Sample Output 1

120

Buying the second and third books makes his understanding levels of all the algorithms 10 or higher, at the minimum cost possible.

Sample Input 2

3 3 10
100 3 1 4
100 1 5 9
100 2 6 5

Sample Output 2

-1

Buying all the books is still not enough to make his understanding levels of all the algorithms 10 or higher.

Sample Input 3

8 5 22
100 3 7 5 3 1
164 4 5 2 7 8
334 7 2 7 2 9
234 4 7 2 8 2
541 5 4 3 3 6
235 4 8 6 9 7
394 3 6 1 6 2
872 8 4 3 7 2

Sample Output 3

1067



Sample input:
3 3 10
60 2 2 4
70 8 7 9
50 2 3 9


Sample output:
120

Submission status: Wrong Answer

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

cc_ = []
for i in range(n):
    cc_.append(c_[i][0])
# print(cc_)

import numpy as np
import itertools
l = np.arange(n)

res1_ = []
res2_ = []
res3_ = []
res4_ = []
res5_ = []
res6_ = []
res7_ = []
res8_ = []
res9_ = []
res10_ = []
res11_ = []
res12_ = []
cc_r_ = []
resList = []
flag = False
for i in range(2,n+1):
    c = list(itertools.combinations(l, i))
    for j in c:
        # print(j)
        res1_ = []
        res2_ = []
        res3_ = []
        res4_ = []
        res5_ = []
        res6_ = []
        res7_ = []
        res8_ = []
        res9_ = []
        res10_ = []
        res11_ = []
        res12_ = []
        cc_r_ = []
        for k in range(len(j)):
            res1_.append(c_[j[k]][1])
            if m >= 2:
                res2_.append(c_[j[k]][2])
            if m >= 3:
                res3_.append(c_[j[k]][3])
            if m >= 4:
                res4_.append(c_[j[k]][4])
            if m >= 5:
                res5_.append(c_[j[k]][5])
            if m >= 6:
                res6_.append(c_[j[k]][6])
            if m >= 7:
                res7_.append(c_[j[k]][7])
            if m >= 8:
                res8_.append(c_[j[k]][8])
            if m >= 9:
                res9_.append(c_[j[k]][9])
            if m >= 10:
                res10_.append(c_[j[k]][10])
            if m >= 11:
                res11_.append(c_[j[k]][11])
            if m >= 12:
                res12_.append(c_[j[k]][12])
            cc_r_.append(cc_[j[k]])
        res1 = sum(res1_)
        if m >= 2:
            res2 = sum(res2_)
        if m >= 3:
            res3 = sum(res3_)
        if m >= 4:
            res4 = sum(res4_)
        if m >= 5:
            res5 = sum(res5_)
        if m >= 6:
            res6 = sum(res6_)
        if m >= 7:
            res7 = sum(res7_)
        if m >= 8:
            res8 = sum(res8_)
        if m >= 9:
            res9 = sum(res9_)
        if m >= 10:
            res10 = sum(res10_)
        if m >= 11:
            res11 = sum(res11_)
        if m >= 12:
            res12 = sum(res12_)
        cc_r = sum(cc_r_)
        if res1 >= x :
            if m >= 2 and res2 >= x:
                resList.append(cc_r)
                flag = True
                if m >= 3 and res3 >= x:
                    resList.append(cc_r)
                    flag = True
                    if m >= 4 and res4 >= x:
                        resList.append(cc_r)
                        flag = True
                        if m >= 5 and res5 >= x:
                            resList.append(cc_r)
                            flag = True
                            if m >= 6 and res6 >= x:
                                resList.append(cc_r)
                                flag = True
                                if m >= 7 and res7 >= x:
                                    resList.append(cc_r)
                                    flag = True
                                    if m >= 8 and res8 >= x:
                                        resList.append(cc_r)
                                        flag = True
                                        if m >= 9 and res9 >= x:
                                            resList.append(cc_r)
                                            flag = True
                                            if m >= 10 and res10 >= x:
                                                resList.append(cc_r)
                                                flag = True
                                                if m >= 11 and res11 >= x:
                                                    resList.append(cc_r)
                                                    flag = True
                                                    if m >= 12 and res12 >= x:
                                                        resList.append(cc_r)
                                                        flag = True
print(min(resList) if flag else -1)

Submission status: Wrong Answer

Solution code:
def python_list_add(in1, in2):
  for i in range(len(in1)):
    in1[i] = in1[i] + in2[i]
  return in1
  
n, m, x = map(int, input().split())
a = []
for i in range(n):
  a.append(list(map(int, input().split())))
ans = -1
s = [0]*(m+1)
for i1 in range(2):
  for i2 in range(2):
    for i3 in range(2):
      for i4 in range(2):
        for i5 in range(2):
          for i6 in range(2):
            for i7 in range(2):
              for i8 in range(2):
                for i9 in range(2):
                  for i10 in range(2):
                    for i11 in range(2):
                      for i12 in range(2):
                        if i1 == 1 and n >= 1:
                          s = python_list_add(s, a[0])
                        if i2 == 1 and n >= 2:
                          s = python_list_add(s, a[1])
                        if i3 == 1 and n >= 3:
                          s = python_list_add(s, a[2])
                        if i4 == 1 and n >= 4:
                          s = python_list_add(s, a[3])
                        if i5 == 1 and n >= 5:
                          s = python_list_add(s, a[4])
                        if i6 == 1 and n >= 6:
                          s = python_list_add(s, a[5])
                        if i7 == 1 and n >= 7:
                          s = python_list_add(s, a[6])
                        if i8 == 1 and n >= 8:
                          s = python_list_add(s, a[7])
                        if i9 == 1 and n >= 9:
                          s = python_list_add(s, a[8])
                        if i10 == 1 and n >= 10:
                          s = python_list_add(s, a[9])
                        if i11 == 1 and n >= 11:
                          s = python_list_add(s, a[10])
                        if i12 == 1 and n >= 12:
                          s = python_list_add(s, a[11])
                        do = True
                        c = s[1:]
                        print(c)
                        for j in c:
                          if j < x:
                            do = False
                            break
                          if do:
                            if ans == -1:
                              ans = s[0]
                            else:
                              ans = min(ans, s[0])
                        s = [0]*(m+1)

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np
n, m, x = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]
l = sorted(l)
l = np.array(l)
ans = np.sum(l, 0)[0]
ans_s = np.sum(l, 0)
if np.any(ans_s[1:] < x):
    print(-1)
    exit()
count = 0
for i in range(1, n + 1):
    for j in itertools.permutations(l, i):
        tot = np.sum(j, 0)
        if np.all(tot[1:] >= x) and tot[0] < ans:
            ans = tot[0]
            count += 1
    if count == 1:
        break
print(int(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())))
y=[]
for i in range(n):
    for v in itertools.combinations(c,i+1):
        y.append(v)
d=0
k=0
p=[]
o=[]
e=[]
for i in range(len(y)):
    for t in range(m):
        for u in range(len(y[i])):
            d+=y[i][u][t+1]
            k+=y[i][u][0]
        p.append(d)
        o.append(k)
    for t in range(len(p)):
        if p[t]<x:
            o=[]
    if o!=[]:
        e.append(o[0])
    d=0
    k=0
    p=[]
    o=[]
if e==[]:
    print(-1)
else:
    print(min(e))

Submission status: Wrong Answer

Solution code:
#C
import numpy as np
flg = True
n,m,x = map(int,input().split())
algo = []
tmp = []
for _ in range(n):
    algo.append(list(map(int,input().split())))
    

algo_n = np.array(algo)
algo_sum = algo_n.sum(axis=0)
gokei = algo_sum.tolist()
money = gokei[0]
gokei = gokei[1:]

#チェックする
for i in range(m):
    if gokei[i] < x:
        flg = False
        print(-1)
        break

algo.sort(key= lambda x:x[0],reverse=True)

#print(algo)
#print(gokei)
# 計算用の関数
def hikizan(lst1,lst2):
#lst1 - lst2
    lst_ans = [0 for _ in range(len(lst1))]
    for i in range(len(lst1)):

        l1 = lst1[i]
        l2 = lst2[i]
        l1 -= l2
        lst_ans[i] = l1
    return lst_ans

def check_lst(lst1,target):
    for i in range(len(lst1)):
        if lst1[i] < target:
            return False
        
    return True

if flg:
    for k in range(n):
        gokei_t = gokei[:]
        money_t = money
        for i in range(k,n):
            if check_lst(hikizan(gokei_t,algo[i][1:]),x):

                gokei_t = hikizan(gokei_t,algo[i][1:])
                money_t -= algo[i][0]
            
            
        tmp.append(money_t)
            
            
 

    print(min(tmp))

Submission status: Wrong Answer

Solution code:
N,M,X = map(int, input().split())
skills=[0]*M
As=[]
Cs=[]
h={}
money=0

for i in range(N):
  data=list(map(int, input().split()))
  C=data.pop(0)
  Cs.append(C)
  A=data
  As.append(A)
  h[i]=max(A)

sorted_h = sorted(h.items(), key=lambda x:x[1], reverse=True)

for i in sorted_h:
  idx=i[0]
  money=money+Cs[idx]
  for j in range(len(skills)):
    skills[j]= skills[j] + As[idx][j]
  if all(k >= X for k in skills):
    print(money)
    exit(0)
print(-1)

Submission status: Wrong Answer

Solution code:
import itertools

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

book=[]
skil=[0]*M
for i in range(N):
    line=list(map(int,input().split(' ')))
    book.append(line)
    skil=list(map(lambda x,y:x+y,skil,line[1:]))

min_p=100000
for n in range(1,N+1):
    for conbo in itertools.combinations(book,n):
        conbo_book=[0]*(1+M)
        for b in list(conbo):
            conbo_book=list(map(lambda x,y:x+y,conbo_book,b))
        if len([m for m in conbo_book[1:] if m>=X])==M:
            if min_p>conbo_book[0]:
                min_p=conbo_book[0]

print(min_p) if min_p<100000 else print("-1")

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np
N,M,X = (int(x) for x in input().split())
S = []
C = []
l = []
ans = 10000000
for i in range(N):
  l.append(i)
for i in range(N):
  s = [int(x) for x in input().split()]
  S.append(s)
npS = np.array(S)
#print(npS)
for i in range(2,N):
  C =  list(itertools.combinations(l,i)) + C
#print(C)
for i in C:
  wa = np.zeros(M+1)
  #print("#",wa,S)
  for j in range(len(i)):
   # print(j,wa)
    wa = wa + S[i[j]]
  #print(i,wa)
  cnt = 0
 # print(len(wa))
  for k in range(0,len(wa)):
    if k == 0:
      continue
    if wa[k] >= X:
      cnt += 1
   # print(cnt,(ans > wa[0]))
    if cnt == M and ans > wa[0]:
      ans = wa[0]
for i in range(N):
  cnt = 0
  for j in range(M):
    if j == 0:
      continue
    if S[i][j] >= X:
      cnt += 1
    if cnt == M and ans > S[i][0]:
      ans = S[i][0]
if ans == 10000000:
  print(-1)
else:
  print(int(ans))

Submission status: Wrong Answer

Solution code:
nums = [int(e) for e in input().split()]
n = nums[0]
m = nums[1]
x = nums[2]

books = []
c = []

min_score = 100000000000000000000

for i in range(n):
    book = [int(e) for e in input().split()]
    c += book[:1]
    books += [book[1:]]

understand = [0] * m
noruma = [x] * m

def calc_understand(a):
    understand = [0] * m
    for book in range(len(books)):
        for i in range(m):
            understand[i] += a[book] * books[book][i]
    return understand


def calc_score(a):
    score = 0
    for i in range(n):
        score += a[i] * c[i]
    return score

# 配列＊配列で全部がX以上になるn個の01からなる配列ができればよい
# DFS
def dfs(a):
    global min_score
    if len(a) == n+1:
        # トータル数と金額を出す
        understand = calc_understand(a)
        understand.sort()
        if noruma <= understand:
            tmp_score = calc_score(a)
            if tmp_score > 0:
                min_score = min(min_score, tmp_score)
        return

    a.append(0)
    while a[len(a) - 1] <= 1:
        dfs(a)
        a[len(a) - 1] += 1

    a.pop(-1)
    return

a = [0]

dfs(a)

if min_score < 100000000000000000000:
    print(min_score)
else:
    print(-1)

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())))

total = ca[0]
for i in range(1, m):
    for j in ca:
        total[i] = total[i] + j[i]

flg = 0
if sorted(total)[0] < x:
    flg = -1

if flg == -1:
    print('-1')

Submission status: Wrong Answer

Solution code:
import itertools
import sys

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

s = [i for i in range(n)]
t = []
list_num = []

for i in range(m):
  t.append(list(map(list, itertools.combinations(s, i + 1))))

for i in t:
  for j in i:
    k = [0] * m
    for z in j:
      k = tuple(x + y for (x,y) in zip(k, num[z]))
    list_num.append(k)


list_num = list(sorted(list_num, key =lambda w : w[0]))

q = []

flag2 = 0

for i in list_num:
  flag = 1
  for j in range(1, len(i)):
    if(i[j] < x):
      flag = 0
      break
  if(flag == 1):
    q.append(i[0])
    flag2 = 1

if(flag2 == 1):
  print(min(q))
else: 
  print(-1)

Submission status: Wrong Answer

Solution code:
import itertools
import numpy 

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

price = []
tmp = []

for i in range(N):
  _ = list(map(int, input().split()))
  price.append(_[0])
  tmp.extend(_[1:])
price = numpy.array(price)
learn = numpy.array(tmp).reshape((N, M))

if min(numpy.sum(learn, axis=0)) < X:
  print(-1)
else:
  success_combs = []
  for k in range(1, N):
    for comb in itertools.combinations(range(N), k):
      if min(numpy.sum(learn[comb, :], axis=0)) >= X:
        success_combs.append(comb)

  min_p = None
  for comb in success_combs:
    p = sum(numpy.take(price,comb))
    if min_p is None:
      min_p = p
    elif min_p > p:
      min_p = p
  print(min_p)

Submission status: Wrong Answer

Solution code:
from itertools import combinations

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

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

array = [i for i in range(N)]
comb = []

for i in range(N-1):
    r = list(map(list,list(combinations(array,i+1))))
    comb.extend(r)

ans = []

for i in comb:
    check = [0 for i in range(M)]
    answer = [0 for i in range(M+1)]
    for j in i:
        for m in range(len(all_text[j])):
            answer[m] += all_text[j][m]
            if m>=1 and answer[m] >= X:
                check[m-1] = 1
    if sum(check) >= M:
        ans.append(answer[0])

if not ans:
    print(-1)
    exit()

ans.sort()
print(ans[0])

Submission status: Wrong Answer

Solution code:
def dfs(i, res, under):
    if i == n:
        bl = True
        for S in range(m):
            if under[S] < x:
                bl = False
                break
        return bl
    if dfs(i + 1, res + c[i], [s + t for (s, t) in zip(under, a[i])]):
        ans.append(res + c[i])
        return
    if dfs(i + 1, res, under):
        ans.append(res)
        return
    return


n, m, x = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
c = [a[s][0] for s in range(n)]
a = [a[t][1:] for t in range(n)]
und = [0]*m
ans = []
dfs(0, 0, und)
if ans == []:
    print(-1)
else:
    print(min(ans))

Submission status: Wrong Answer

Solution code:
import sys;input=lambda:sys.stdin.readline().rstrip();aint=lambda:int(input());ints=lambda:list(map(int,input().split()))
import math;floor,ceil=lambda x:int(math.floor(x)),lambda x:int(math.ceil(x))
from functools import reduce;gcd=lambda*x:reduce(math.gcd,x);lcm=lambda*x:reduce(lambda x,y:(x*y)//gcd(x,y),x,1)
import numpy as np
from collections import deque
from itertools import combinations
import bisect
Yes=lambda b:print("Yes"if b else"No");YES=lambda b:print("YES"if b else"NO")
is_even=lambda x:True if x%2==0 else False

def main():
    n,m,x=ints()
    ca=[]
    val=[]
    for _ in range(n):
        inp=ints()
        ca.append(inp)
        flg=1
        for i in range(1,m+1):
            flg = 0 if inp[i]<x else None
        val.append(inp[0]) if flg==1 else None
    for num in range(2,n+1):
        for v in combinations(ca,num):
            vnp = np.array(v)
            s=vnp.sum(axis=0)
            flg=1
            for i in range(1,m+1):
                if s[i]<x:
                    flg = 0
            val.append(s[0]) if flg==1 else None
    
    print(-1 if not val else min(val))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

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

C = [list(map(int, input().split())) for _ in range(N)]
# print(C)
sum_C = np.sum(C,axis=0)
# print(sum_C)

for num in sum_C:
    if num < X:
        print(-1)
        exit()

cost = float("inf")
for ij in [0, 1]:
    for ii in [0, 1]:
        for i in range(M+1):
            cc = sorted(C, key=lambda x:x[0], reverse=ij)
            ccc = np.array(sorted(cc, key=lambda x:x[i], reverse=ii))
            # print("ccc", ccc)
            sum_Ccopy = np.zeros(M+1)
            for j in range(N):
                sum_Ccopy += ccc[j]

                # print(np.all(sum_Ccopy[1:] >= X))
                # print(sum_Ccopy[0])
                if np.all(sum_Ccopy[1:] >= X):
                    cost = min(cost, sum_Ccopy[0])
                    # print(sum_Ccopy[0])
                    # print("sum_Ccopy", sum_Ccopy)
                # print(cost)
    
print(int(cost))

Submission status: Wrong Answer

Solution code:
nums = [int(e) for e in input().split()]
n = nums[0]
m = nums[1]
x = nums[2]

books = []
c = []

min_score = 10000000000000

for i in range(n):
    book = [int(e) for e in input().split()]
    c += book[:1]
    books += [book[1:]]

understand = [0] * m
noruma = [x] * m

def calc_understand(a):
    understand = [0] * m
    for book in range(len(books)):
        for i in range(m):
            understand[i] += a[book] * books[book][i]
    return understand


def calc_score(a):
    score = 0
    for i in range(n):
        score += a[i] * c[i]
    return score

# 配列＊配列で全部がX以上になるn個の01からなる配列ができればよい
# DFS
def dfs(a):
    global min_score
    if len(a) == n+1:
        # トータル数と金額を出す
        understand = calc_understand(a)
        understand.sort()
        if noruma <= understand:
            tmp_score = calc_score(a)
            if tmp_score > 0:
                min_score = min(min_score, tmp_score)
        return

    a.append(0)
    while a[len(a) - 1] <= 1:
        dfs(a)
        a[len(a) - 1] += 1

    a.pop(-1)
    return

a = [0]

dfs(a)

if min_score < 10000000000000:
    print(min_score)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
M=[0 for _ in range(m+1)]
S=[]
for i in range(n):
    S.append(list(map(int,input().split())))
#print('initial S\n',S)
for i in range(n):
    for j in range(m+1):
        M[j]+=S[i][j]
end=0
for j in range(1,m+1):
    if M[j]<x:
        end=1
#print('M\n',M)
if end==0:
    S.sort()
    S.reverse()
    #print('S\n',S)
    for i in range(n):
        flag=0
        for j in range(1,m+1):
            if M[j]-S[i][j]<x:
                flag=1
        if flag==0:
            for j in range(m+1):
                M[j]-=S[i][j]
    print(M[0])
else:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from itertools import combinations

def main():
    N, M, X = [int(i) for i in input().split()]
    C, A = [], []
    for _ in range(N):
        ca = [int(i) for i in input().split()]
        C.append(ca[0])
        A.append(ca[1:])
    
    for m in range(M):
        if sum(a[m] for a in A) < X:
            print(-1)
            return
    
    sets = []
    comb_ix = [comb for i in range(2, len(A) + 1) for comb in combinations(range(len(A)), i)]
    for m in range(M):
        tmp_lst = []

        for comb in comb_ix:
            a = [a[m] for i, a in enumerate(A) if i in comb]
            if sum(a) >= X:
                tmp_lst.append(comb)
        
        sets.append(frozenset(tmp_lst))
    
    intersection = set.intersection(*map(set, sets))
    res = sum(C)
    for comb in intersection:
        sum_c = sum(c for i, c in enumerate(C) if i in comb)
        if sum_c < res:
            res = sum_c
    
    print(res)
    
main()

Submission status: Wrong Answer

Solution code:
import itertools

def list_add(in1, in2):
   return list(map(sum, zip(in1, in2)))

N, M ,X = map(int, input().split())
C = [0] * N
A = [[] * M] * N
for i in range(N):
    T = list(map(int, input().split()))
    C[i] = T[0]
    A[i] = T[1:]

n = [i for i in range(N)]
c_sum = 0
min_sum = 10e5
for i in range(N):
    flag = 0
    for v in itertools.combinations(n,i+1):
        c_sum = 0
        At = [0] * M
        for j in range(len(v)):
            At = list_add(At, A[v[j]])
            c_sum += C[v[j]]
        overX = [k for k in At if k >= X]
        if len(overX) == M:
            flag = 1
            min_sum = min([min_sum, c_sum])
if flag == 1:
    print(min_sum)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import itertools

def main():
    n,m,x = map(int,input().split())
    c = [[0] * (m+1)]*n
    sum_l = [0]*m
    min_money = 1000000
    money = 0
    cnt = 0
    t = 0

    result  = []

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

    for i in range(1,n+1):
        for conb in itertools.combinations(list(range(n)),i):
            result.append(list(conb))
            cnt += 1

    # print(result)
    # print(cnt)
    for i in range(cnt):
        for j in range(len(result[i])):
            for k in range(m):
                sum_l[k] += c[result[i][j]][k+1]
            money += c[result[i][j]][0]

            for k in range(m):
                if sum_l[k] >= x:
                    t += 1
            if t == m:
                if min_money > money:
                    min_money = money
            t = 0
        # print(result[i],sum_l,money,min_money)
        sum_l = [0]*m
        money = 0

    if min_money == 1000000:
        print(-1)
    else:
        print(min_money)

    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def python_list_add(in1, in2):
  for i in range(len(in1)):
    in1[i] = in1[i] + in2[i]
  return in1
  
n, m, x = map(int, input().split())
a = []
for i in range(n):
  a.append(list(map(int, input().split())))
ans = -1
s = [0]*(m+1)
for i1 in range(2):
  for i2 in range(2):
    for i3 in range(2):
      for i4 in range(2):
        for i5 in range(2):
          for i6 in range(2):
            for i7 in range(2):
              for i8 in range(2):
                for i9 in range(2):
                  for i10 in range(2):
                    for i11 in range(2):
                      for i12 in range(2):
                        if i1 == 1 and n >= 1:
                          s = python_list_add(s, a[0])
                        if i2 == 1 and n >= 2:
                          s = python_list_add(s, a[1])
                        if i3 == 1 and n >= 3:
                          s = python_list_add(s, a[2])
                        if i4 == 1 and n >= 4:
                          s = python_list_add(s, a[3])
                        if i5 == 1 and n >= 5:
                          s = python_list_add(s, a[4])
                        if i6 == 1 and n >= 6:
                          s = python_list_add(s, a[5])
                        if i7 == 1 and n >= 7:
                          s = python_list_add(s, a[6])
                        if i8 == 1 and n >= 8:
                          s = python_list_add(s, a[7])
                        if i9 == 1 and n >= 9:
                          s = python_list_add(s, a[8])
                        if i10 == 1 and n >= 10:
                          s = python_list_add(s, a[9])
                        if i11 == 1 and n >= 11:
                          s = python_list_add(s, a[10])
                        if i12 == 1 and n >= 12:
                          s = python_list_add(s, a[11])
                        do = True
                        for j in s[1:]:
                          if j < x:
                            do = False
                            break
                          if do:
                            if ans == -1:
                              ans = s[0]
                            else:
                              ans = min(ans, s[0])
                        s = [0]*(m+1)

print(ans)

Submission status: Wrong Answer

Solution code:
from numpy import array

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


c=[]
d=[0]*(m+1)
for i in range(n):
    c1=array(list(map(int,input().split())))
    c.append(c1)
    d+=c1


#print(c)
#c.sort(key=lambda x: x[0], reverse=True)
#print(c)
#print(d)

if(False in [x<=i for i in d[1:]]):
   print(-1)
   exit()

#print(d[0])

for i in range(n):
    e=d-c[i]
    #print(e)
    if(False not in [x<=i for i in e[1:]]):
        d=e

print(d[0])

Submission status: Wrong Answer

Solution code:
import numpy as np

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

C = np.array([list(map(int, input().split())) for _ in range(N)])
# print(C)
sum_C = np.sum(C,axis=0)
# print(sum_C)

for num in sum_C:
    if num < X:
        print(-1)
        exit()

cost = float("inf")
for ij in [0, 1]:
    for ii in [0, 1]:
        for i in range(M+1):
            cc = sorted(C, key=lambda x:x[0], reverse=ij)
            ccc = np.array(sorted(cc, key=lambda x:x[i], reverse=ii))
            # print("ccc", ccc)
            sum_Ccopy = np.zeros(M+1)
            for j in range(N):
                sum_Ccopy += ccc[j]

                # print(np.all(sum_Ccopy[1:] >= X))
                # print(sum_Ccopy[0])
                if np.all(sum_Ccopy[1:] >= X):
                    cost = min(cost, sum_Ccopy[0])
                    # print(sum_Ccopy[0])
                    print("sum_Ccopy", sum_Ccopy)
                # print(cost)
    
print(int(cost))

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m,x = map(int,input().split())
l = []
for i in range(n):
    l.append(np.array(input().split(),dtype=int)) 
import itertools
num = [i for i in range(n)]
min = 100000000000000
k = 1
while k <n+1:
    a = list(itertools.combinations(num, k))
    for i in range(len(a)):
        total =np.zeros(m+1,dtype=int)
        for j in range(len(a[i])):
            total +=l[a[i][j]]
        if np.sum(np.where(total < x)[0]) <=0:
            if min > total[0]:
                min = total[0]
                k = 15
    k +=1
if min == 100000000000000:
  print(-1)
else:
  print(min)

Submission status: Wrong Answer

Solution code:
import numpy as np
n, m, x = [int(k) for k in input().split()]
c = np.zeros(n, dtype=int)
a = np.zeros((n, m), dtype=int)
rikai_a = np.zeros(m, dtype=int)
bool_c = np.full(n, True)
for i in range(n):
    c[i], *a[i] = [int(k) for k in input().split()]
money = 0
finish = 0
ave = np.zeros(n)
for i in range(n):
    ave[i] = np.average(np.array([aa / x if aa < x else 1 for aa in a[i]])) / c[i]
for i in np.argsort(ave)[::-1]:
    for j in range(m):
        if rikai_a[j] < x:
            break
    else:
        break
    rikai_a[:] += a[i][0]
    money += c[i]
for i in range(m):
    if rikai_a[i] >= x:
        finish += 1
if finish == m:
    print(money)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
from collections import deque

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

row = [i for i in range(1, N+1)]
ans = float("INF")
for i in range(1, M+1):
  for v in combinations(row, i):
    q = deque(v)
    cost = 0
    Asum = [0]*M
    while q:
      a = q.popleft() - 1
      cost += CA[a][0]
      for j in range(M):
        Asum[j] += CA[a][j+1]
    flag = True
    for m in range(M):
      if Asum[m] < X:
        flag = False
    if flag:
      ans = min(ans, cost)
if ans == float("INF"):
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

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

book=[]
skil=[0]*M
sp=100000
for i in range(N):
    line=list(map(int,input().split(' ')))
    book.append(line)
    skil=list(map(lambda x,y:x+y,skil,line[1:]))
    if len([i for i in line[1:] if i>=X])==M:
        if sp>line[0]:
            sp=line[0]

if sp<100000:
    print(sp)
    exit()

if [i for i in skil if i<X]:
    print ("-1")
else:
    min_p=100000
    for n in range(2,N+1):
        for conbo in itertools.combinations(book,n):
            conbo_book=[0]*(1+M)
            for b in list(conbo):
                conbo_book=list(map(lambda x,y:x+y,conbo_book,b))
            if len([m for m in conbo_book[1:] if m>=X])==M:
                if min_p>conbo_book[0]:
                    min_p=conbo_book[0]

    print(min_p)

Submission status: Wrong Answer

Solution code:
from collections import deque
import itertools

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

li = deque()

sum = -1
ans = 0
for i in range(n):
    li.append(list(map(int, input().split())))

for i in range(1,n+1):
    for v in itertools.combinations(li, i):
        ok = True
        for j in range(1,m+1):
            ans = 0
            for k in v:
                ans += k[j]
                if ans >= x:
                    break
            if ans < x:
                ok = False
                break

        if ok == True:
            s=0
            for j in range(i):
                s+=v[j][0]
            if sum > s or sum == -1:
                sum=s
    if sum > -1:
        break


print(sum)

Submission status: Wrong Answer

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

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


for i in range(m):
    tate_sum=0
    for w in range(n):
        tate_sum =  tate_sum + num_list[w][i+1]
    if tate_sum < x:
        print('-1')
        break