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())
cost=[]
kekka=[]
res=[]
for _ in range(n):
    a=list(map(int, input().split()))
    cost+=[a[0]]
    kekka+=[a[1:]]
for i in range(2**n):
    sum=[0]*m
    money=0
    for j in range (n):
        if i>>j & 1:
            for k in range(m):
                sum[k]+=kekka[j][k]
            money+=cost[j]
    if sum>[x,x,x]:res+=[money]
print("-1" if res == [] else min(res))

Submission status: Wrong Answer

Solution code:
# import sys
# input = sys.stdin.readline
import itertools

# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
    n, m, x = input_list()
    books = {}
    contents = {}
    for i in range(n):
        c = input_list()
        books[i] = c[0]
        contents[i] = c[1:m+1]

    if n == 1:
        if sum(contents[0]) >= x:
            print(books[0])
        else:
            print(-1)
        exit()

    for i in range(1, n+1):
        ans = []
        for v in itertools.combinations(range(n), i):
            ok = [False] * m
            a = 0
            understands = [0] * m
            for vi in v:
                for index, val in enumerate(contents[vi]):
                    understands[index] += val
                    if understands[index] >= x:
                        ok[index] = True
                a += books[vi]
            if all(ok):
                ans.append(a)
        if len(ans) > 0:
            print(min(ans))
            exit()

    print(-1)


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# import sys
# input = sys.stdin.readline
import itertools

# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
    n, m, x = input_list()
    books = {}
    contents = {}
    for i in range(n):
        c = input_list()
        books[i] = c[0]
        contents[i] = c[1:m+1]

    if n == 1:
        if sum(contents[0]) >= x:
            print(books[0])
        else:
            print(-1)
        exit()
    
    for i in range(2, n+1):
        ans = []
        for v in itertools.combinations(range(n), i):
            ok = [False] * m
            a = 0
            understands = [0] * m
            for vi in v:
                for index, val in enumerate(contents[vi]):
                    understands[index] += val
                    if understands[index] >= x:
                        ok[index] = True
                a += books[vi]
            if all(ok):
                ans.append(a)
        if len(ans) > 0:
            print(min(ans))
            exit()
    print(-1)


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# import sys
# input = sys.stdin.readline
import itertools

# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
    n, m, x = input_list()
    books = {}
    contents = {}
    s = {}
    for i in range(n):
        c = input_list()
        books[i] = c[0]
        contents[i] = c[1:m+1]
        s[i] = sum(c[1:m+1])

    for i in range(2, n+1):
        ans = []
        for v in itertools.combinations(range(n), i):
            ok = [False] * m
            a = 0
            understands = [0] * m
            for vi in v:
                for index, val in enumerate(contents[vi]):
                    understands[index] += val
                    if understands[index] >= x:
                        ok[index] = True
                a += books[vi]
            if all(ok):
                ans.append(a)
        if len(ans) > 0:
            print(min(ans))
            exit()
    print(-1)


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N, M, X = map(int,input().split())
C = [list(map(int,input().split())) for x in range(N)] 
#最初だけ金額なことに注意
skill = [0]*M
flag = [0]*M    #スキルが身についてるかのフラグ
saisyou = 10**7
for p in range(2**N):
    for q in range(N):
        if p >> q & 1:      #q+1冊目の本について
            money += C[q][0]
            for r in range(M):  #各スキルの理解度追加
                skill[r] += C[q][r+1]
    print(skill)
    for s in range(M):
        if skill[s] >= X:
            flag[s] = 1
    if 0 not in flag and money < saisyou:
        saisyou = money
    money = 0
    skill = [0]*M
    flag = [0]*M
if saisyou == 10**7:
    saisyou = -1
print(saisyou)

Submission status: Wrong Answer

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

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

max = 2**n
ans = 10**18
for i in range(max) :
    num = i
    cost = 0
    r = [0]*m
    check = 0
    for j in range(n) :
        f = num%2
        num = num//2
        if f == 0 :
            continue
        cost += c[j]
        r = [x+y for (x,y) in zip(r,a[j])]
    if all(elem >= x for elem in r) :
        ans = min(ans,cost)
        break

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

Submission status: Wrong Answer

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

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

max = 2**n
ans = 10**18
for i in range(max) :
    num = i
    cost = 0
    r = [0]*m
    for j in range(n) :
        f = num%2
        num = num//2
        if f == 0 :
            continue
        cost += c[j]
        r = [x+y for (x,y) in zip(r,a[j])]
    if all(elem >= x for elem in r) :
        ans = min(ans,cost)

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

Submission status: Wrong Answer

Solution code:
# ABC167C
import sys
import numpy as np
N, M, X = map(int, input().split())
C = np.array([list(map(int, input().split())) for _ in range(N)])
#Cを小さい順に並び替え、合計を１行で出す
#合計から大きい順に引いていき、Xを下回るAがないか確認していく

SC = C[np.argsort(C[:,0]),:]
ans = np.sum(C, axis=0)

if np.all(ans[1:] >= X) == False:
    print(-1)
    sys.exit()

S,j = 0,(N - 1)
while j >= 1:
    S = ans - SC[j]
    j -= 1
    if np.all(S[1:] >= X) == False:
        continue
    else:
        ans = S
print(int(ans[:1]))

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
N, M, X = map(int, input().split())
C = np.array([list(map(int, input().split())) for _ in range(N)])
#Cを小さい順に並び替え、合計を１行で出す
#合計から大きい順に引いていき、Xを下回るAがないか確認していく

SC = C[np.argsort(C[:,0]),:]
ans = np.sum(C, axis=0)

if np.all(ans[1:] >= X) == False:
    print(-1)
    sys.exit()

S,j = 0,(N - 1)
while j >= 0:
    S = ans - SC[j]
    j -= 1
    if np.all(S[1:] >= X) == False:
        continue
    else:
        ans = S
print(int(ans[:1]))

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
N, M, X = map(int, input().split())
C = np.array([list(map(int, input().split())) for _ in range(N)])
#Cを小さい順に並び替え、合計を１行で出す
#合計から大きい順に引いていき、Xを下回るAがないか確認していく

SC = C[np.argsort(C[:,0]),:]
ans = np.sum(C, axis=0)

if np.all(ans[1:] >= X) == False:
    print(-1)
    sys.exit()

S,j = 0,(N - 1)
while j >= 0:
    S = ans - SC[j]
    j -= 1
    if np.all(S[1:] >= X) == False:
        continue
    else:
        ans = S
print(ans[:1])

Submission status: Wrong Answer

Solution code:
import itertools

n,m,x = map(int,input().split())
c = [0]*n
a = [[]]*n

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

p = [i for i in range(n)]
ans = 10**10
for index in itertools.permutations(p):
    cost = 0
    r = [0]*m
    f = 0
    for i in index :
        cost += c[i]
        r = [x+y for (x,y) in zip(r,a[i])]
        if all(elem >= x for elem in r) :
            ans = min(ans,cost)
            break

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

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
a=[]
e=10**8
for i in range(n):
    b=list(map(int,input().split()))
    a.append(b)
for i in range(2**n):
    c=[0]*(m+1)
    s=0
    for j in range(n):
        if i>=2**(n-j-1):
            i-=2**(n-j-1)
            c=[x+y for (x,y) in zip(a[j],c)]
    for j in range(m):
        if c[1+j]<x:
            s+=1
    print(c)
    if s==0 and e>c[0]:
        e=c[0]
if e==100000000:
    print(-1)
else:
    print(e)

Submission status: Wrong Answer

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

for j in range(2 ** N):
    li_d = [0] * M
    sum = 0
    for k in range(N):
        if (j & (1 << k)):
            li_d = [x + y for x in li_d for y in li_a[k][1:]]
            sum += li_a[k][0]
    if li_d >= [X] * M:
        li_b.append(sum)

if li_b == []:
    print(-1)

else:
    li_b.sort()
    print(li_b[0])

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
def Ii():return int(sys.stdin.buffer.read())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))
  
n,m,x = Mi()
a = []
b=[0]*m
b = np.array(b)
for i in range(n):
  a.append(Li())
  
ans = 10**6
def DFS(cost,start,skill):
  global ans
  if min(skill) >= x:
    ans = min(ans,cost)
    return ans
  for i in range(start,n):
    DFS(cost+a[i][0],i+1,skill+np.array(a[i][1:]))
  return ans

a = DFS(0,0,b)
if a == 10**6:
  a = -1
print(a)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
def Ii():return int(sys.stdin.buffer.read())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))
  
n,m,x = Mi()
a = []
b=[0]*m
b = np.array(b)
for i in range(n):
  a.append(Li())
  
ans = 10**5+1
def DFS(cost,start,skill):
  global ans
  if min(skill) >= x:
    ans = min(ans,cost)
    return ans
  for i in range(start,n):
    DFS(cost+a[i][0],i+1,skill+np.array(a[i][1:]))
  return ans

a = DFS(0,0,b)
if a == 10**5+1:
  a = -1
print(a)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    n,m,x=map(int,input().split())
    l=[list(map(int,input().split())) for _ in range(n)]

    ans=10**10

    for i in range(2 ** n):
        skill=[0]*m
        cost=0
        for j in range(n):  # このループが一番のポイント
            if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
                cost+=l[j][0]
                for k in range(m):
                    skill[k]+=l[j][k-1]
        if all(skill[i]>=x for i in range(m)):
            ans=min(ans,cost)



    print(ans if ans!=10**10 else -1)
    
    
resolve()

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
c=[]
for i in range(n):
  a=[int(i) for i in input().split()]
  c.append(a)
import numpy as np
c=np.array(c)
ans=float('inf')
for i in range(1,2**n):
  p=[0]*m
  cost=0
  for j in range(n):
    if(i>>j)&1==1:
      cost+=c[j][0]
      p+=c[j][1:]
    if min(p)>=x:
      print(min(ans,cost))
      exit()
       
if ans==float('inf'):
  ans=-1
  print(ans)

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
c=[]
for i in range(n):
  a=[int(i) for i in input().split()]
  c.append(a)
import numpy as np
c=np.array(c)
ans=float('inf')
for i in range(1,2**n):#0番目は[0][0][0]で購入しないので数えない
  p=[0]*m
  cost=0
  for j in range(n):
    if(i>>j)&1==1:
      cost+=c[j][0]
      p+=c[j][1:]
    if min(p)>=x:
      print(min(ans,cost))
      exit()
       
if ans==float('inf'):
  ans=-1
  print(ans)

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
c=[]
for i in range(n):
  a=[int(i) for i in input().split()]
  c.append(a)
import numpy as np
c=np.array(c)
ans=float('inf')
for i in range(1,2**n):#0番目は[0][0][0]で購入しないので数えない
  p=[0]*m
  cost=0
  for j in range(n):
    if(i>>j)&1==1:
      cost+=c[j][0]
      p+=c[j][1:]
    if min(p)>=x:
      print(min(ans,cost))
      exit()
       
if ans==float('inf'):
       print(-1)

Submission status: Wrong Answer

Solution code:
import itertools

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

ans = 10**8

for i in range(2**N):
    score = [0] * M
    total = 0
    for j in range(1,N+1):
        if ((i >> j) & 1):
            total += a[j][0]
            for k in range(M):
                score[k] += a[j][k+1]
        
    if min(score) >= X:
        ans = min(ans, total)

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

Submission status: Wrong Answer

Solution code:
import numpy as np

n,m,x=map(int,input().split())
c=[]
a=[]
ans=10**6

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

a=np.array(a)


for i in range(2**n):
  level=np.zeros(m)
  price=0
  for j in range(n):
    if ((i>>j)&1):
      level+=a[j]
      price+=c[j]
  bottom=int(np.amin(level))
  if bottom>=x and price<ans:
    ans=price
if ans==10**6:
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m,x=map(int,input().split())
hon=[]
for i in range(n):
    hon.append(list(map(int, input().split())))
hon = np.array(hon)
t = np.array( [0] * n )
ans = 10**6
while True:
    get = np.zeros(m+1)
    flag = False
    for i in range(n):
        if t[i]==1:
            get += hon[i]
    if np.all(get[1:] >= x):
        ans = min(ans, get[0])
    if t.sum() == n:
        break
    for i in range(n):
        if t[i] == 0:
            t[i]=1
            break
        else:
            t[i]=0

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m,x=map(int,input().split())
hon=[]
for i in range(n):
    hon.append(list(map(int, input().split())))
hon = np.array(hon)
print(hon)
t = np.array( [0] * n )
ans = 10**6
while True:
    get = np.zeros(m+1)
    flag = False
    for i in range(n):
        if t[i]==1:
            get += hon[i]
    
    print(get)
    if np.any(get[1:] >= x):
        ans = min(ans, get[0])
    if t.sum() == n:
        break
    for i in range(n):
        if t[i] == 0:
            t[i]=1
            break
        else:
            t[i]=0

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m,x=map(int,input().split())
hon=[]
for i in range(n):
    hon.append(list(map(int, input().split())))
hon = np.array(hon)
print(hon)
t = np.array( [0] * n )
ans = 10**6
while True:
    get = np.zeros(m+1)
    flag = False
    for i in range(n):
        if t[i]==1:
            get += hon[i]
    for i in range(n):
        if t[i] == 0:
            t[i]=1
            break
    print(get)
    if np.any(get[1:] >= x):
        ans = min(ans, get[0])
    if t.sum() == n:
        break

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

Submission status: Wrong Answer

Solution code:
N, M, X = list(map(int, input().split()))
ca_list = [list(map(int, input().split())) for _ in range(N)]
c = [ca_list[i][0] for i in range(N)]
a = [ca_list[i][1:] for i in range(N)]
ans = sum(c)
check = False

for i in range(2**N):
    total = 0
    skills = [0] * M
    for j in range(M):
        if (i >> j) & 1:
            total += c[j]
            skills = [k + l for k, l in zip(a[j], skills)]
    if all([z >= X for z in skills]):
        ans = min(total, ans)
        check = True

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

Submission status: Wrong Answer

Solution code:
N, M, X = list(map(int, input().split()))
ca_list = [list(map(int, input().split())) for _ in range(N)]
c = [ca_list[i][0] for i in range(N)]
a = [ca_list[i][1:] for i in range(N)]
ans = sum(c)
# check = False
count = 0

for i in range(2**N):
    total = 0
    skills = [0] * M
    for j in range(M):
        if (i >> j) & 1:
            total += c[j]
            skills = [k + l for k, l in zip(a[j], skills)]
    if all([i >= X for i in skills]):
        ans = min(total, ans)
        # check = True
        count += 1

if count == 0:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
N, M, K = list(map(int, input().split()))
ca_list = [list(map(int, input().split())) for i in range(N)]
c = [ca_list[i][0] for i in range(N)]
a = [ca_list[i][1:] for i in range(N)]
ans = sum(c)
check = False

for i in range(2**N):
    total = 0
    skills = [0] * M
    for j in range(M):
        if ((i >> j) & 1):
            total += c[j]
            skills = [k + l for k, l in zip(a[j], skills)]
    if all([i >= K for i in skills]):
        ans = min(total, ans)
        check = True

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

Submission status: Wrong Answer

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


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


ans = 10**10

for i in range(2**N):
    print("Hi")
    tmp_cost = []
    tmp_Algo = []
    for j in range(N):

        if ((i>>j)&1):
            tmp_cost.append(C[j])
            tmp_Algo.append(A[j])


    
    #これで各々の値は収容できた。
    # 値段と空白のリストを作成して、もし条件を満たせば入れていくシステム。
    cost = 0
    flag = [0]*M

    for nedan in tmp_cost:
        cost = cost + nedan
        for singlelis in tmp_Algo:
            print(singlelis)

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np

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

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

A = np.array(A)
C = np.array(C)

answer = 10**6
for comb in itertools.product([0, 1], repeat= N):
    cost = 0
    A_memo = np.zeros(M, dtype=int)

    for i in range(N):
        if not comb[i]:
            continue

        A_memo += A[i]
        cost += C[i]

    if (A_memo >= X).sum() == M:
        answer = min(answer, cost)

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

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np

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

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

A = np.array(A)
C = np.array(C)

answer = 10**6
for comb in itertools.product([0, 1], repeat= N):
    cost = 0
    A_memo = np.zeros(M, dtype=int)

    for i in range(N):
        if not comb[i]:
            continue

        A_memo += A[i]
        cost += C[i]

    if (A_memo >= X).sum() == M:
        answer = min(answer, cost)

if answer > 10**5:
    print(-1)
else:
    print(answer)

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np

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

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

A = np.array(A)
C = np.array(C)

answer = 10**5 + 1
for comb in itertools.product([0, 1], repeat= N):
    cost = 0
    A_memo = np.zeros(M, dtype=int)
    for i in range(N):
        if not comb[i]:
            continue

        A_memo += A[i]
        cost += C[i]

    if (A_memo >= X).sum() == M:
        answer = min(answer, cost)

if answer == 10**5 + 1:
    print(-1)
else:
    print(answer)

Submission status: Wrong Answer

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

INF = 10 ** 9
ans = INF

for s in range(0, 1 << n):
  smart = [0] * m
  cost_sum = 0

  for i in range(n):
    if (s >> i) % 2 == 0:
      continue
    cost_sum += c[i]

    for j in range(m):
      smart[j] += a[i][j]

    ok = True
    for j in range(m):
      if smart[j] < x:
        ok = False
      if ok:
        ans = min(ans, cost_sum)

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C_fix
# CreatedDate:  2020-06-27 14:37:15 +0900
# LastModified: 2020-06-27 15:23:03 +0900
#


import os
import sys
from itertools import combinations
import numpy as np
# import pandas as pd


def main():
    n, m, x = map(int, input().split())
    s = []
    for i in range(n):
        s.append(list(map(int, input().split())))
    s = np.array(s)
    total = 1000000


    for i in range(1, n+1):
        for lili in list(combinations(range(n), i)):
            s_list = np.zeros((m+1), dtype=np.int32)
#            print(lili)
            for li in lili:
                s_list += s[li]
#            print(s_list[1:])

            if (s_list[1:] >= x).all() and s_list[0] < total:
                total = s_list[0]
    if total == 1000000:
        print(-1)
    else:
        print(total)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

for i in range(1, 2**n):
    s = [0]*m
    count = 0
    ps = 0
    for j in range(n):
        if (i >> j) & 1:
            ps += a[j][0]
            for k in range(m):
                s[k] += a[j][k+1]
                if s[k] >= x:
                    count += 1
    if count == m:
        p = min(ps, p)
        
if p == float('inf'):
    print(-1)
else:
    print(p)

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
C=[[] for i in range(n)]
for i in range(n):
  A=list(map(int,input().split()))
  C[i]=[A[0],A[1:]]
  
  
cost=3987642542
for bit in range(1<<n):
  #print([j for j in range(n) if bit>>j & 1 ])
  for i in range(m):
    if sum([C[j][1][i] for j in range(n) if bit>>j & 1 ])<x:
      break
  else:
    cost=min(cost, sum([C[j][0] for j in range(n) if bit>>j & 1 ]))
    #print(cost)
print(cost if cost<1000000 else -1)

Submission status: Wrong Answer

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

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

ave = [[0, i] for i in range(n)]

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

for i in range(n):
    ave[i][0] = c[i] / ave[i][0]
ave.sort()

ans = 0
now = [0] * m
for i in range(n):
    for j in range(m):
        now[j] += a[ave[i][1]][j]
    ans += c[ave[i][1]]
    for j in range(m):
        f = True
        if now[j] < x:
            f = False
            break
    if f:
        print(ans)
        exit()

Submission status: Wrong Answer

Solution code:
import sys
from itertools import combinations, chain
from operator import itemgetter
from functools import reduce

n, m, x = map(int, next(sys.stdin).split())
books = [tuple(map(int, s.split())) for s in sys.stdin]

book_combinations = chain.from_iterable(combinations(books, i)
                                        for i in range(m + 1))

def total_price(book_list, _price_getter=itemgetter(0)):
  return sum(map(_price_getter, book_list))
def min_score(book_list, _score_getter=itemgetter(slice(1, None))):
  book_scores = map(_score_getter, book_list)
  scores = [0] * m
  for book_score in book_scores:
    for i, score in enumerate(book_score):
      scores[i] += score
  return min(scores)

price_score_list = ((total_price(book_list), min_score(book_list))
                    for book_list in book_combinations)
prices = (price for price, score in price_score_list if score >= x)
answer = min(prices, default=-1)
print(answer)

Submission status: Wrong Answer

Solution code:
import sys
from itertools import combinations, chain
from operator import itemgetter
from functools import reduce

n, m, x = map(int, next(sys.stdin).split())
books = [tuple(map(int, s.split())) for s in sys.stdin]

book_combinations = chain.from_iterable(combinations(books, i)
                                        for i in range(1, m + 1))

def total_price(book_list, _price_getter=itemgetter(0)):
  return sum(map(_price_getter, book_list))
def min_score(book_list, _score_getter=itemgetter(slice(1, None))):
  book_scores = map(_score_getter, book_list)
  scores = [0] * m
  for book_score in book_scores:
    for i, score in enumerate(book_score):
      scores[i] += score
  return min(scores)

price_score_list = ((total_price(book_list), min_score(book_list))
                    for book_list in book_combinations)
prices = (price for price, score in price_score_list if score >= x)
answer = min(prices, default=-1)
print(answer)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
n,m,x = map(int,input().split())
input_list = [np.array(list(map(int,input().split()))) for _ in range(n)]
temp_fee = sys.maxsize 
for i in range(n**2):
    list2 = [np.array([0]*(m+1))]
    for j in range(n):
        if (i >> j) &1 == 1:
            list2.append(input_list[j])
    list3 = sum(list2)
    if min(list3[1:])>=x and list3[0]<temp_fee:
        temp_fee = list3[0]
if temp_fee != sys.maxsize:
    print(temp_fee)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n, m, x = list(map(int, input().split()))
c = [0] * n
a = [[]  for _ in range(n)]
INF = float('inf')
ans = INF

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

for s in range(1<<n):
    smart = [0] * m
    cost = 0
    for i in range(n):
        if not(s>>i & 1):continue
        cost += c[i]
        for j in range(m):
            smart[j] += a[i][j]

    flg = True
    for i in range(m):
        if smart[i] < 10:
            flg = False
    if flg:
        ans = min(ans, cost)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n, m, x = map(int, input().split())
c = []
for _ in range(n):
    c.append(np.array(list(map(int, input().split()))))


def ok(lst):
    for tokuten in lst:
        if tokuten < x:
            return False
    return True


inf = 100000000000000000000
ans = inf

for s in range(n**2):
    cost = 0
    d = np.array([0] * m)
    for i in range(n):
        if s >> i & 1:
            cost += c[i][0]
            d += c[i][1:]
    if ok(d):
        ans = min(ans, cost)

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

Submission status: Wrong Answer

Solution code:
import numpy as np

n, m, x = map(int, input().split())
c = []
for _ in range(n):
    c.append(np.array(list(map(int, input().split()))))


def ok(lst):
    for tokuten in lst:
        if tokuten < x:
            return False
    return True


inf = 1000000000000000
ans = inf

for s in range(n**2):
    cost = 0
    d = np.array([0] * m)
    for i in range(n):
        if s >> i & 1:
            cost += c[i][0]
            d += c[i][1:]
    if ok(d):
        ans = min(ans, cost)

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

Submission status: Wrong Answer

Solution code:
import sys

import numpy as np

n, m, x = map(int, input().split())
c = []
for _ in range(n):
    c.append(np.array(list(map(int, input().split()))))


def ok(lst):
    for tokuten in lst:
        if tokuten < x:
            return False
    return True


c.sort(key=lambda e: e[0])

total = np.array([0] * (m + 1))

for book in c:
    total += book
    if ok(total[1:]):
        print(total[0])
        sys.exit()
print(-1)

Submission status: Wrong Answer

Solution code:
import sys

import numpy as np

n, m, x = map(int, input().split())
c = []
for _ in range(n):
    c.append(np.array(list(map(int, input().split()))))


def ok(lst):
    for tokuten in lst:
        if tokuten < 10:
            return False
    return True


c.sort(key=lambda e: e[0])

total = np.array([0] * (m + 1))

for book in c:
    total += book
    if ok(total[1:]):
        print(total[0])
        sys.exit()
print(-1)

Submission status: Wrong Answer

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

def python_list_add(in1, in2):
    return [a + b for a, b in zip(in1, in2)]

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

m = 1e9
for i in range(2 ** N):
	bag = []
	total = [0] * M
	for j in range(N):
		if((i >> j) & 1):
			bag.append(A[j][0])
			total = python_list_add(total, A[j])
	if(all(elem >= X for elem in total[1:])):
		m = min(total[0],m)
if m == 1e9:
	m = -1
print(m)

Submission status: Wrong Answer

Solution code:
from operator import add
N, M, X = map(int, input().split())


def toBook(line):
    xs = line.split()
    cost = int(xs[0])
    values = list(map(int, xs[1:]))
    return (cost, values)


Books = [toBook(input()) for i in range(N)]
maxCost = 10 ** 15


def isSatisfied(xs):
    return all([x >= X for x in xs])


def rec(i, proficiency, totalCost):
    if i == N:
        if isSatisfied(proficiency):
            return totalCost
        else:
            return maxCost
    else:
        _proficiency = list(map(add, proficiency, Books[i][1]))
        _totalCost = totalCost + Books[i][0]
        if isSatisfied(_proficiency):
            return _totalCost
        else:
            cost1 = rec(i + 1, proficiency, totalCost)
            cost2 = rec(i + 1, _proficiency, _totalCost)
            return min(cost1, cost2)


cost = rec(0, [0] * M, 0)
if cost == maxCost:
    print("-1")
else:
    print(cost)