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:
import itertools

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

C = [0] * N
A = [list() for _ in range(N)]

for i in range(N):
    C[i], *A[i] = map(int, input().split())

ans = sum(C)

b = False
for i in range(1, N+1):
    for j in itertools.combinations(range(N), i):
        print(j)
        a = [0] * M
        for k in j:
            for l in range(M):
                a[l] += A[k][l]
        print("a ", a)
        for aa in a:
            if aa < X:
                break
        else:
            ans = min(ans, sum(C[k] for k in j))
            print(ans, "!!!")
            b = True
    if b:
        break

if not b:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    n, m, x = [int(e) for e in input().split()]
    CA = [[int(e) for e in input().split()] for i in range(n)]

    ans = 10 ** 6
    for i in range(1, 2 ** n):
        bs = format(i, f'0{n}b')

        cs = 0
        Sm = [0] * m
        for i in range(n):
            if bs[i] == '1':
                cs += CA[i][0]
                for mi in range(m):
                    Sm[mi] += CA[i][mi + 1]

        if all(sm >= x for sm in Sm):
            ans = min(cs, ans)

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, m, x = [int(i) for i in input().strip().split()]
matrix = [[int(i) for i in input().strip().split()] for _ in range(n)]

values = []
for idx, j in enumerate(matrix):
    tmp = sum(j[1:])
    values.append([idx, tmp / j[0]])
values.sort(key=lambda s:s[1], reverse=True)

tmp = [0 for _ in range(m)]
result = 0
succeed = False
for i in values:
    if all([i >= x for i in tmp]):
        break
    result += matrix[i[0]][0]
    tmp = [i + j for i, j in zip(tmp, matrix[i[0]][1:])]
print(result if all([i >= x for i in tmp]) else -1)

Submission status: Wrong Answer

Solution code:
from operator import add
n,m,x=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]

ans=10**5+1
for i in range(2**n):
  c=0
  s=[0]*m
  for b in range(n):
    if i>>b&1:
      c+=l[b][0]
      s=map(add,s,l[b][1:])
  if all([e>=x for e in s]):
    ans=min(ans,c)
if ans==10**5+1:
  ans=-1
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
n,m,x=map(int,input().split())
lists=[]
array=[0 for i in range(m+1)]
ans=[]
for i in range(n):
    lists.append(list(map(int,input().split())))
for i in range(n+1):
    for pair in itertools.combinations(lists,i):
        for j in range(len(pair)):
            array=list(map(lambda x,y: x+y,array,list(pair[j])))
        for k in range(m):
            if array[k+1]<x:
                break
            else:
                ans.append(array[0])
        array=[0 for i in range(m+1)]
print(min(ans) if ans else "-1")

Submission status: Wrong Answer

Solution code:
import itertools
from operator import add

n, m, x = map(int, input().split())
C = [[]] * (n + 1)
ans = 100000

for i in range(1, n + 1):
    C[i] = list(map(int, input().split()))
for i in range(1, n + 1):
    pares = list(itertools.combinations(range(1, n + 1), i))
    for pare in pares:
        A = [0] * (m + 1)
        for el in pare:
            A = list(map(add, A, C[el]))
        flag = True
        for a in A[1:]:
            if not a >= x:
                flag = False
                break
        if flag:
            if A[0] < ans:
                ans = A[0]
if not ans == 100000:
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
n, m, x = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
a.sort(reverse=True)
a = np.array(a)
ans = np.array([0 for i in range(m+1)])
for i in a:
    ans += i

for i in ans[1:]:
    if i < x:
        print(-1)
        exit()

cans = np.copy(ans)

for i in a:
    cnt = 0
    tmp = ans - i
    for j in tmp[1:]:
        if j >= x:
            cnt += 1
            if cnt == m:
                ans -= i

cans -= ans
cnt = 0
for i in cans[1:]:
    if i >= x:
        cnt += 1
        if cnt == m:
            print(min(ans[0], cans[0]))
            exit()

print(ans[0])

Submission status: Wrong Answer

Solution code:
import itertools

def main():

    n,m,x = map(int,input().split())
    C = []
    A = []
    for i in range(n):
        array = list(map(int,input().split()))
        C.append(array[0])
        A.append(array[1:])
    cost = 10**6
    for i in range(1,n+1):
        combs = itertools.combinations(range(n), i)
        for comb in combs:
            skill = [0]*m
            cost_tmp = 0
            for e in comb:
                cost_tmp += C[e]
                for j in range(m):
                    skill[j] += A[e][j]
            for j in range(m):
                if skill[j] < x:
                    break
                cost = min(cost, cost_tmp)
    if cost == 10**6:
        print(-1)
        return
    print(cost)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import itertools

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

ok = False
cur_price = 10 ** 6
min_price = 0
for i in range(1, n + 1):
    answers = list(itertools.combinations(range(n), i))
    # print(answers)
    for ans_list in answers:
        sum_list = [0] * (m + 1)
        for ans in ans_list:
            # print(all_list[int(ans[0])])
            sum_list = [a + b for a, b in zip(sum_list, all_list[int(ans)])]
        # print(sum_list)
        if min(sum_list[1:]) >= x:
            if sum_list[0] < cur_price:
                cur_price = sum_list[0]
                ok = True

if ok:
    print(cur_price)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
def mips():
    return map(int,input().split())
def msps():
    return map(str,input().split())

import sys
import itertools
N,M,X = mips()
know = dict()
price = [[] for _ in range(N)]
L = []
C = []
for i in range(M):
    know[i] = 0
for i in range(N):
    L.append([i for i in mips()])
    C.append(L[i][0])
    L[i].remove(L[i][0])
Money = []
paid = 0 
K = []
No = 0
P = []
Q = [i for i in range(N)]
for i in range(N):
    P.append(list(itertools.combinations(Q,i)))
for k in range(N):
    for el in P[k]:
        for book in el:
            K = L[book] 
            paid += C[book]
            for i in range(M):
                know[i] += K[i]
        for i in range(M):
            if know[i] < X:
                No = 1
                break
        if No == 0:
            Money.append(paid)
        paid = 0
        No = 0
        for i in range(M):
            know[i] = 0
if Money == []:
    print("-1")
else:
    print(min(Money))

Submission status: Wrong Answer

Solution code:
import sys
import itertools
import numpy as np

if __name__ == '__main__':
    n,m,x = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))
    c, a = [], np.ndarray((n,m))

    for i in range(n):
        ls  = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))
        tc, ta = ls[0], ls[1:]
        c.append(tc)
        a[i] = ta

    mini = 1000000
    for q in range(n):
        indices = list(itertools.permutations(list(range(n)), q))[1:]
        for ix in indices:
            if all([True if r >= 10 else False for r in sum([a[i] for i in ix])]):
                #print(sum([a[i] for i in ix]), sum([c[i] for i in ix]))
                tmini = sum([c[i] for i in ix])
                if mini > tmini:
                    mini = tmini
    if mini == 1000000:
        print('-1')
    else:
        print(mini)

Submission status: Wrong Answer

Solution code:

n,m,x = map(int,input().split())
c = [[int(i) for i in input().split()] for _ in range(n)]
import itertools
max_=-1
for i in range(n):
    c_list = list(itertools.combinations(c, i+1))
    for j in c_list:
        d=[0]*m
        for k in j:
            d = [x+y for (x,y) in zip(d,k)]
        f=1
        for l in range(1,m):
            if d[l] < x:
                f=0
                break
        if f==1:
            if max_ ==-1:
                max_ = d[0]
            elif d[0] < max_:
                max_ = d[0]

print(max_)

Submission status: Wrong Answer

Solution code:
import itertools 
def solve():
    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 = n*1e5
    for i in range(n):
        for j in itertools.combinations(range(n), i+1):
            cnt = [0]*m
            for k in j:
                for l in range(m):
                    cnt[l] += a[k][l]
            for s in range(m):
                if cnt[s] < x:
                    break
                if s == m-1:
                    num = 0
                    for q in j:
                        num += c[q]
                    ans = min(ans, num)

            
    return ans
    

print(solve())

Submission status: Wrong Answer

Solution code:
import numpy as np
n, m, x = map(int, input().split())
c = []
nls = list()
for i in range(n):
    l = list(map(int, input().split()))
    c.append(l)

nls = np.array(c)
f=0
if not all(np.sum(nls, axis=0) > x):
    f = 1
    print("-1")   
else:
    import itertools
    import pprint
    result=[]
    final =[]
    for n in range(1,len(c)+1):
        for conb in itertools.combinations(c, n):
            result.append(list(conb))
    for l in result:
        l=np.array(l)
        tmp = np.sum(l, axis=0)
#         print("tmp", tmp)
        if all(tmp > x):
            final.append(tmp.tolist())
    final.sort()
    print(final[0][0])

Submission status: Wrong Answer

Solution code:
import itertools
import sys
import numpy as np

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

result = []
for n in range(2 ** N):
    ii = [0] * N
    for i in range(N):
        if (n >> i) & 1:
            ii[i] = 1
    # print(ii)
    tmp = [0] * (M + 1)
    for j in range(len(ii)):
        if ii[j] == 1:
            tmp = (np.array(tmp) + np.array(C[j])).tolist()
    result.append(tmp)


def ex(array):
    for i in array:
        if i < X:
            return False
    return True


min_value = sys.maxsize
result.sort()
for r in result:
    if ex(r):
        print(r[0])
        exit()

print(-1)

Submission status: Wrong Answer

Solution code:
import itertools

def main(N, M, X, CA):
    cand = []
    for n in range(N):  # n個選ぶ
        for ca in itertools.combinations(CA, n):
            s, price = f(ca)
            if all(i >= X for i in s):
                cand.append(price)
    if len(cand) == 0:
        print(-1)
    else:
        print(min(cand))


def f(lst):
    s = [0 for _ in range(M)]
    price = 0
    for ca in lst:
        price += ca[0]
        for i in range(M):
            s[i] += ca[i+1]
    return s, price





if __name__ == '__main__':
    N, M, X = list(map(int, input().split()))
    CA = []
    for _ in range(N):
        CA.append(list(map(int, input().split())))

    main(N, M, X, CA)

Submission status: Wrong Answer

Solution code:
# m 個のアルゴリズムを学びたい
# n 冊の参考書
# x 必要な理解度
n,m,x = map(int,input().split())
book = [list(map(int,input().split())) for _ in range(n)]
#n,m,x = 12,3,1
#book = [[1, 2, 2, 2], [100, 10, 10, 10], [100, 10, 10, 10], [100, 10, 10, 10], [100, 10, 10, 10], [100, 10, 10, 10], [100, 10, 10, 10], [100, 10, 10, 10], [100, 10, 10, 10], [100, 10, 10, 10], [100, 10, 10, 10], [100, 10, 10, 10]]

def listadd(a,b,n):
  c = [0] * n
  for i in range(n):
    c[i] = a[i]+b[i]
  return c

ans = 0
for candi in range(0,2**n): # 読む本の候補リスト
  s = [0] * (m + 1)

  for i in range(n):
    #print(candi >> i & 1) 
    if candi >> i & 1:
      s = listadd(s,book[i],m+1)
  
  ck = 1
  for j in range(m):
    if s[j] < x:
      ck = 0
      break
    else:
      ck *= 1

  if ck:
    if ans:
      ans = min(ans,s[0])
    else:
      ans = s[0]

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import itertools
d = defaultdict(int)

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

for i in range(N):
    for j in range(1, M + 1):
        d[j] += L[i][j]

for i in range(M):
    if (d[i + 1] < X):
        print('-1')
        exit()

n = []
for i in range(N):
    n.append(i)

p = []
for i in range(1, N + 1):
    p.append(itertools.combinations(n, i))


for v in p:
    for i in v:
        d2 = defaultdict(int)
        for j in range(len(i)):
            for k in range(0, M + 1):
                if (k == 0):
                    d2[0] += L[i[j]][0]
                else:
                    d2[k] += L[i[j]][k]
        count = 0
        for p, q in d2.items():
            if(p == 0):
                continue
            else:
                if(q >= X):
                    count += 1
        if (count == len(d2) - 1):
            print(d2[0])
            exit()

Submission status: Wrong Answer

Solution code:

def solve(m, x, bag):

    p = [0]*(m+1)

    for i in range(len(bag)):
        for j in range(m+1):
            p[j] += bag[i][j]

    for i in range(1,m):
        if p[i] < x:
            return pow(10, 8)
    else:
        return p[0]

if __name__ == '__main__':

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

    mini = pow(10, 8)

    for i in range(2**n):
        bag = []
        #print("p{} : ".format(i), end="")

        for j in range(n):
            if((i >> j) & 1):
                bag.append(l[j])
        #print(bag)
        r = solve(m, x, bag)
        if mini > r:
            mini = r

    if mini == pow(10, 8):
        print(-1)
    else:
        print(mini)

Submission status: Wrong Answer

Solution code:
def main():
    n, m, x = [int(e) for e in input().split()]
    CA = [[int(e) for e in input().split()] for i in range(n)]

    ans = 10 ** 6
    for i in range(1, 2 ** n + 1):
        bs = format(i, f'0{n}b')

        cs = 0
        Sm = [0] * m
        for i in range(n):
            if bs[i] == '1':
                cs += CA[i][0]
                for mi in range(m):
                    Sm[mi] += CA[i][mi + 1]

        if all(sm >= x for sm in Sm):
            ans = min(cs, ans)

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
from random import choice,randint
inp=sys.stdin.readline
out=sys.stdout.write
flsh=sys.stdout.flush
 
sys.setrecursionlimit(10**9)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def MI(): return map(int, inp().strip().split())
def LI(): return list(map(int, inp().strip().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]
def LI_(): return [int(x)-1 for x in inp().strip().split()]
def LF(): return [float(x) for x in inp().strip().split()]
def LS(): return inp().strip().split()
def I(): return int(inp().strip())
def F(): return float(inp().strip())
def S(): return inp().strip()
def pf(s): return out(s+'\n')
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

# def func1(a,b,cl,mat,ans,m,n,x,a2):
#     flag = 1
#     for i in range(m):
#         if a2[i]<x:
#             flag=0
#     if flag:
#         ans[0]=min(a,ans[0])
#     for i in range(b,n):
#         for j in range(m):
#             a2[j]+=mat[i][j]
#         func1(a+cl[i],b+1,cl,mat,ans,m,n,x,a2)
#         for j in range(m):
#             a2[j]-=mat[i][j]

def main():
    n,m,x=MI()
    cl=[]
    mat =[]
    ans = [inf]
    # a2=[0]*20
    for i in range(n):
        ls = LI()
        cl.append(ls[0])
        mat.append(ls[1:])
    # func1(0,0,cl,mat,ans,m,n,x,a2)
    for i in range(n):
        for j in range(n):
            flag = 1
            for e in range(m):
                sm =0
                for f in range(i,j+1):
                    sm+=mat[f][e]
                if sm<x:
                    flag=0
            if flag:
                sm1 = 0
                for f in range(i,j+1):
                    sm1+=cl[f]
                ans[0]=min(ans[0],sm1)

    if ans[0]==inf:
        ans[0] = -1
    print(ans[0])

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

goal = [x] * (m)

def infer(ans):
    for i in range(m):
        if goal[i] > ans[i]:
            return False
    return True

cost = 10 ** 5
flag = False
for i in range(2**n):
    bag = [0] * (m)
    total = 0
    for j in range(n):  
        if ((i >> j) & 1):
            bag = [bag[k] + a[j][k] for k in range(m)]
            total += c[j]
    
    if infer(bag):
        cost = min(cost, total)
        flag = True
print(cost if flag else -1)

Submission status: Wrong Answer

Solution code:
def plus(lis):
    ans = [0]*12
    for x in lis:
        ans = list(map(sum2,ans,x))
    return ans

def sum2(a,b):
    return a+b
#for check(lis,X):
#    all( x > X for x in lis):
ans = -1

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

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

for i in range (2**N):
    #print(i)
    tmp = list()
    for j in range(N):
        if (i>>j)&1 == 1:
            tmp.append(A[j])
            #print(tmp)
    score = plus(tmp)
    #print(score)
    if(all([x >= X for x in score[1:]])):
        if ans == -1:
            ans = score[0]
        else:
            ans = min(ans,score[0])

            
print(ans)

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
c = []
a = [[] for _ in range(n)]
for i in range(n):
  inp = list(map(int, input().split()))
  c.append(inp[0])
  for j in range(m):
    a[i].append(inp[j+1])
print(c)
print(a)
kumi=1
for i in range(n):
  kumi *= 2
print(kumi)
  
min_score = 10000000000000
for i in range(1, kumi):
  t = [0 for _ in range(m)]
  p = 0
  ni = format(i, 'b').zfill(n)
  for j in range(n):
    if(ni[j]=="1"):
      for kk in range(m):
        t[kk] += a[j][kk]
      p += c[j]
  flag = True
  #print(t)
  for j in range(m):
    if(t[j] < x):
      flag = False
  if(flag):
    if(min_score > p):
      min_score = p
      
if(min_score == 10000000000000):
  print(-1)
else:
  print(min_score)

Submission status: Wrong Answer

Solution code:
N,M,X = map(int,input().split())
Datas=[]
Ms = [0]*M
flag=True
for n in range(N):
  temp=list(map(int, input().split()))
  for i in range(M):
    Ms[i]+=temp[i+1]
  Datas.append(temp)

for i in range(M):
  if Ms[i] < X:
    flag=False
    
MIN=1000000
if flag:
  
  print(91)
else:
  print(-1)

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:
n,m,x = map(int,input().split())
ac = [input().split() for _ in range(n)]

ac = sorted(ac)
money = 0
for i in range(n):
  for j in range(m+1):
    if j == 0:
      money += int(ac[i][0])
      continue
    print(ac[i][j])

Submission status: Wrong Answer

Solution code:
import numpy as np
n, m, x = map(int, input().split())
c = []
nls = list()
for i in range(n):
    l = list(map(int, input().split()))
    c.append(l)

nls = np.array(c)
f=0
if not all(np.sum(nls, axis=0) > x):
    f = 1
    print(-1)   
else:
    import itertools
    import pprint
    result=[]
    final =[]
    for n in range(1,len(c)+1):
        for conb in itertools.combinations(c, n):
            result.append(list(conb))
    for l in result:
        l=np.array(l)
        tmp = np.sum(l, axis=0)
#         print("tmp", tmp)
        if all(tmp > x):
            final.append(tmp.tolist())
    final.sort()
    print(final[0][0])

Submission status: Wrong Answer

Solution code:
def list_add(li1, li2):
    return list(map(sum,zip(li1,li2)))
N, M, X = map(int, input().split(" "))
list = []
for i in range(N):
    list.append([int(i) for i in input().split(" ")])
list.sort()
price = 0
knowledge = []
priceList = []
for i in range(N):
    price = price + list[i][0]
    if i == 0:
        knowledge = list[0][1: M + 1]
    else:
        tmp2 = [x + y for (x, y) in zip(knowledge, list[i][1:M+1])]
        knowledge = tmp2
    # 全部足しても足りないとき
    if i == N - 1 and min(knowledge) < X:
        print(-1)
        exit()
    # 目標を超えたとき
    if min(knowledge) >= X:
        for j in range(i, -1, -1):
            searchList = [x - y for (x, y) in zip(knowledge, list[j][1: M + 1])]
            if min(searchList) >= X:
                knowledge = searchList
                price = price - list[j][0]
        priceList.append(price)
print(min(priceList))

Submission status: Wrong Answer

Solution code:
import numpy as np 


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


s_list = list()

for i in range(n):
    line = list(map(int, input().split()))
    s_list.append([line[0], np.array(line[1:], dtype=int)])


cands = list()
# cost, value
cands.append([0, np.zeros(m, dtype=int)])


for l in s_list:
    next_cands = list()
    for c in cands:
        next_cands.append([c[0] + l[0], c[1] + l[1]])
    cands += next_cands


min_cost = 10**12
for l in cands:
    if (l[1] >= x).all() and l[0] < min_cost:
        min_cost = l[0]


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

Submission status: Wrong Answer

Solution code:
# C
# Skill Up

import itertools
import numpy as np

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

data_tensor = np.empty((n,m))
c_list = np.empty((n,1))

ans = 100000000
flag = True

for i in range(n):
    _list = list(map(int, input().split()))
    c_list[i], data_tensor[i] = _list[0], _list[1:]
    
buy_tensor = itertools.combinations_with_replacement([0,1],n)

for _list in buy_tensor:
    _list_np = np.array(_list)
    _list_np = _list_np.reshape(-1,1)
    _sum_list = np.sum(data_tensor * _list_np, axis=0)
    if np.min(_sum_list) >= x:
        _ans = np.sum(c_list * _list_np)
        if _ans < ans:
            ans = int(_ans)
            flag = False
        
if flag:
    ans = -1

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import itertools as it


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

    book = []

    for n in range(N):
        book.append(list(map(int, input().split())))
    
    ok = False

    for n in range(1, N+1):
        if ok:
            break
        mini = 10**10
        for v in it.combinations([x for x in range(1, N+1)], n):

            us = [0]*(M+1)
            flag = True
            for i in list(v):
                for j in range(1, M+1):
                    us[j] += book[i-1][j]
            for i in us[1:]:
                if i < X:
                    flag = False

            if flag:
                ok = True
                temp = 0
                for i in v:
                    temp += book[i-1][0]
                if mini > temp:
                    mini = temp
    
    if ok:
        print(mini)
    else:
        print(-1)
                    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import itertools
N, M, X= map(int, input().split())
l = []
for i in range(N):
  l.append(list(map(int, input().split())))

candidate = []
for i in range(1, M+1):
  for comb in itertools.combinations(range(N), i):
    price = 0
    understand = [0]*M
    for j in range(i):
      price += l[comb[j]][0]
      understand = [x + y for (x, y) in zip(understand, l[comb[j]][1:])]
    if all(elem >= X for elem in understand):
      candidate.append(price)

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

Submission status: Wrong Answer

Solution code:
def solve():
    N, M, X = map(int, input().split())
    AC = []
    ans = 10**8
    for n in range(N):
        AC.append(list(map(int, input().split())))
    for i in range(2**N):
        level = [0]*M
        cost = 0
        for j in range(N):
            if ((i >> j) & 1):
                for l in range(M):
                    level[l] += AC[j][l+1]
                cost += AC[j][0]
        if (min(level) >= X) and (ans > cost):
            ans = cost
    if ans == 10**6:
        print(-1)
    else:
        print(ans)


solve()

Submission status: Wrong Answer

Solution code:
import itertools
n,m,x=map(int,input().split())
lists=[]
array=[0 for i in range(m+1)]
ans=[]
for i in range(n):
    lists.append(list(map(int,input().split())))
for i in range(n):
    for pair in itertools.combinations(lists,i+1):
        for j in range(len(pair)):
            array=list(map(lambda x,y: x+y,array,list(pair[j])))
        for k in range(m):
            if array[k+1]<x:
                break
            else:
                ans.append(array[0])
        array=[0 for i in range(m+1)]
print(min(ans) if ans else "-1")

Submission status: Wrong Answer

Solution code:
import numpy as np

# # n = int(input())
n, m, x = map(int, input().split())
# # b = [int(input()) for i in range(n)]
ca = [list(map(int, input().split())) for i in range(n)]

# n = 3
# x = 10

# ca = [[60, 2, 2, 4], [70, 8, 7, 9], [50, 2, 3, 9]]
cat = np.transpose(ca)
# print(ca)

def check(q):
  money = sum(cat[0, q])
  skill = np.sum(cat[1:, q], axis = 1)
  skill_ok = np.all(skill >= x)
  # print(q, money, skill, skill_ok)
  return money if skill_ok else 9999999

best = 999999

for i in range(0, 2**n):
  two = list(bin(i)[2::])[::-1]
  twotwo = list(map(int, two))
  saiyou = np.where(twotwo)[0]
  # print(saiyou, cat[0, saiyou])
  cost = check(saiyou)
  best = min(cost, best)

# print(np.where(list(bin(8)[2:])))

res = best if not best == 999999 else -1

print(res)

Submission status: Wrong Answer

Solution code:
# WA になる理由がわからん
def solve():
    N, M, X = map(int, input().split())
    AC = []
    ans = 10**8
    for n in range(N):
        AC.append(list(map(int, input().split())))
    for i in range(2**N):
        level = [0]*M
        cost = 0
        for j in range(N):
            if ((i >> j) & 1):
                for l in range(M):
                    level[l] += AC[j][l+1]
                cost += AC[j][0]
        if (min(level) >= X) and (ans > cost):
            ans = cost
    if ans == 10**6:
        print(-1)
    else:
        print(ans)


solve()

Submission status: Wrong Answer

Solution code:
import itertools
n,m,x=map(int,input().split())
l=list()
for i in range(n):
    l.append(list(map(int,input().split())))
for i in range(1,n+1):
    for j in itertools.combinations(l,i):
        r=[0 for i in range(m)]
        for k in j:
            a=0
            p=0
            for i in range(1,m+1):
                r[i-1]+=k[i]
                a+=r[i-1]>=x
            if a==m:
                for c in j:
                    p+=c[0]
                print(p)
                quit()
print(-1)

Submission status: Wrong Answer

Solution code:
n,m,x = map(int, input().split())
data_list = []
for i in range(n):
    data_list.append(list(map(int, input().split())))
    
base = 100000
price = 1200000

data_ = [0]*(m+1)
for i in range(len(data_list)):
    for j in range(m+1):
        data_[j] += data_list[i][j]
        
min_data = min(data_[:-1])
                
if min_data < x:
    print(-1)
else:
    for i in range(2 ** n):
        value_list = [0]*(m+1)
        value = []
        for j in range(n):  # このループが一番のポイント
            if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
                value.append(data_list[j])
                    
        for i in range(len(value)):
            for j in range(m+1):
                value_list[j] += value[i][j]
                
        if min(value_list[:-1]) >= x and value_list[0] < price:
            price = value_list[0]
    
    print(price)

Submission status: Wrong Answer

Solution code:
import itertools
N,M,X=map(int,input().split())
ans=12*10**5
List=[]
for _ in range(N):
  List.append([int(i) for i in input().split()])
for i in range(0,N):
  for j in itertools.combinations(range(N),i+1):
    tmp=[0]*(M+1)
    for k in j:      
      for l in range(M+1):
        tmp[l]+=List[k][l]
    if len([m for m in tmp[1:] if m>=X])==M:
      ans=min(ans,tmp[0])
if ans==12*10**5:
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

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

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

y = 0
for i in range(2 ** n):
  lb = [0]*(m+1)
  for j in range(n):
    if ((i >> j) & 1):
      lb = [x + y for (x, y) in zip(lb, la[j][:])] 
  frg=1
  print(lb)
  for h in range(m):
    if lb[h+1]<x:
      frg=0
  if frg==1:
    if lb[0] <= y or y==0:
      y=lb[0]
  print(y)
  del lb[:]
print(y if y>0 else -1)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

N, M, X = map(int, sys.stdin.readline().rstrip().split())

Cs = [0] * N
As = [[] * M] * N
for i in range(N):
    A = list(map(int, sys.stdin.readline().rstrip().split()))
    C = A[0]
    A = A[1:]
    Cs[i] = C
    As[i] = A

sumAs = np.array([sum(A) for A in zip(*As)])
sumCs = sum(Cs)

if any(sumAs < X):
    print(-1)
    sys.exit()
else:
    for c in reversed(np.argsort(Cs)):
        next_sumAs = sumAs - np.array(As[c])
        if any(next_sumAs < X):
            continue
        else:
            sumAs = next_sumAs
            sumCs -= Cs[c]

print(sumCs)