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 = list(map(int, input().split()))
C = []
A = []

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


for i in range(1, N+1):
    comb_list = list(itertools.product(range(N), repeat=i))
    flag_i = False
    min_cost = 10**7
    for comb in comb_list:
        know = [0] * M
        cost = 0
        for book in comb:

            for i in range(M):
                know[i] += A[book][i]
            cost += C[book]
        
        #達成チェック
        flag = True
        for i in range(M):
            if (know[i] < X):
                flag = False
                
        
        if (flag):
            flag_i = True
            if (min_cost > cost):
                min_cost = cost
    if (flag_i):
        print(min_cost)
        exit(0)

print(-1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)

# 1 ✕ N
N, M, X = list(map(int, input().rstrip().split()))

# # N ✕ M (2D array)
A = list(input().rstrip().split() for _ in range(N))

ans = 1e9
for bit in range(2 ** N):
    total = 0
    array = [0 for _ in range(0, M)]

    for i in range(N):
        if bit & 1 << i:
            total += int(A[i][0])
            for j in range(0, M):
                array[j] += int(A[i][j])

    found = True
    for i in range(M):
        if array[i] < X:
            found = False

    if found:
        ans = min(ans, total)

print(-1 if ans == 1e9 else ans)

Submission status: Wrong Answer

Solution code:
N,M,X = map(int,input().split())
C = [0]*N
A = [[0] for _ in range(N)]
for i in range(N):
    tmp = list(map(int,input().split()))
    C[i] = tmp[0]
    A[i] = tmp[1:M+1]
f = False
money_min = 100000000000
for i in range(1,2**N-1):
    use = format(i,"0{}b".format(N))
    money = 0
    understand = [0]*M
    for j in range(N):
        if use[j] == "1":
            money += C[j]
            for k in range(M):
                understand[k] += A[j][k]
    if min(understand) >= X and money < money_min:
        money_min = money
        f = True

if f:
    print(money_min)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import itertools

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

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

ans = float('inf')
L = list(range(N))
for i in range(1, N+1):
    for comb in itertools.combinations(L, i):
        kingaku = 0
        TM = [0]*M
        for c in comb:
            kingaku += C[c][0]
            for i in range(M):
                TM[i] += C[c][i]
        isOk = True
        for m in TM:
            if m < X:
                isOk = False
                break

        if isOk:
            ans = min(ans, kingaku)

if ans == float('inf'):
    print("-1")
else:
    print(ans)

Submission status: Wrong Answer

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

ans = -1

import itertools

for v in itertools.product([0,1], repeat=N):
    ls = [0]*(M+1)
    for i in range(N):
        if v[i] == 1:
            ls = [x + y for (x, y) in zip(ls, A[i])]

    flag = 1 
    for i in range(1,M+1):
        if ls[i] < 10:
            flag = 0
    
    if flag == 1 and (ans == -1 or ans > ls[0]):
        ans = ls[0]     

print(ans)

Submission status: Wrong Answer

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

l = [0] * m
c = 0

for i in range(n):
  ca = list(map(int, input().split()))
  lt = 0
  for j in range(1, m + 1):
    t = l[j - 1] + ca[j]
    l[j - 1] = t
    if t >= x:
      lt += 1
  c += ca[0]
  if lt == m:
    print(c)
    c = 0
    break

if c != 0:
  print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m,x=map(int,input().split())
ans=10**5
s=[list(map(int,input().split())) for _ in range(n)]
for i in range(2**n):
  t=np.zeros(m+1)
  for j in range(n):
    if (i>>j)&1:
      t=t+np.array(s[j])
  if all(t[1:]>=x):
    ans=min(t[0],ans)
if ans==10**5:
  print(-1)
else:
  print(int(ans))

Submission status: Wrong Answer

Solution code:
from itertools import permutations
N, M, X = map(int, input().split())
list1 = []
for i in range(N):
    l = list(map(int, input().split()))
    list1.append(l)
ans = 10000000000
flag = False
test = [i for i in range(N)]
for l in permutations(test, N):
    understand = [0 for j in range(M)] 
    money = 0
    for i in l:
        money += list1[i][0]
        for j in range(M):
            understand[j] += list1[i][j]
        if all(elem >= X for elem in understand):
            flag = True
            ans = min(ans, money)
            break
print(ans) if flag else print(-1)

Submission status: Wrong Answer

Solution code:
import itertools
n, m, x = map(int, input().split())
ca = []
for _ in range(n): ca.append(list(map(int, input().split())))
ans = 10 ** 6
t = False
for i in range(1, n+1):
    for idx in itertools.combinations(range(n), i):
        l = [0]*m
        c = 0
        for j in idx:
            for k, v in enumerate(ca[j][1:]):
                l[k] += v
            c += ca[j][0]
        if min(l) >= x:
            ans = min(ans, c)
            t = True
if t: print(ans)
else: print(-1)

Submission status: Wrong Answer

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

ans = 10**10
for b in range(2**n):
  skils = [0]*m
  tmp = 0
  
  for i in range(n):
    if b&(1<<i):
      for j in range(m):
        skils[j] += li[i][j+1]
      tmp += li[i][0]

        
  if skils>=X:
    ans = min(ans, tmp)

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

Submission status: Wrong Answer

Solution code:
from itertools import permutations
N, M, X = map(int, input().split())
CAs = [[int(n) for n in input().split()] for _ in range(N)]

MAX = 10**5 + 1

for i in range(1, N + 1):
    min_ = MAX
    for cas in permutations(CAs, i):
        rikai = [0] * M
        kakaku = 0
        for ca in cas:
            for j in range(M):
                rikai[j] += ca[j + 1]
            kakaku += ca[0]
        if len(list(filter(lambda x: x < X, rikai))) == 0:
            min_ = min(min_, kakaku)
    if min_ < MAX:
        print(min_)
        break
else:
    print('-1')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

def input_one_number():
    return int(input())

def input_multiple_number():
    return map(int, input().split())

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


N,M,X =  input_multiple_number()

listC = [0]*N
tableA = [[0]*M for i in range(N)]

for i in range(N):
	iii = input_multiple_number_as_list()
	listC[i] = iii[0]
	for j in range(M):
		tableA[i][j] = iii[j+1]

ans = 10000000000

import itertools as it
for i in it.product(range(2), repeat=N):
	isOK = True
	price = 0
	listM = [0]*M
	for j in range(N):
		if i[j] == 1:
			for qqq in range(M):
				listM[qqq] += tableA[j][qqq]
			price += listC[j]
	for skils in range(M):
		isOK = (listM[skils] >= X) and isOK

	if isOK:
		ans = min(price,ans)

print(ans)

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split()) 
c_l = []
a_l = []

for _ in range(n):
    a_list = list(map(int, input().split())) 
    c_l.append(a_list[0])
    a_l.append(a_list[1:])

min_c = 9999999999
for i in range(2 ** n):
    bag_c = []
    bag_a = []
    for j in range(n):
        if ((i >> j) & 1):  
            bag_c.append(c_l[j])  
            bag_a.append(a_l[j])
        l = len(bag_a)
        c_sum = 0
        s_sum = [0]*m
        for ii in range(l):
            c_sum += bag_c[ii]
            for mm in range(m):
                s_sum[mm] += bag_a[ii][mm]
        if min(s_sum) >= x and c_sum < min_c:
            min_c = c_sum
print(min_c)

Submission status: Wrong Answer

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

import itertools


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

    min_c = 10 ** 6
    for i in range(2 ** n):
        cur_c = 0
        a_list = [0] * m
        for j in range(n):
            is_use = i & (2 ** j)
            if is_use:
                cur_c += ca_list[j][0]
                a_list = [a_list[k] + ca_list[j][k + 1] for k in range(m)]
        if all(k >= x for k in a_list) and cur_c < min_c:
            min_c = cur_c
    print(min_c if min_c != 10 **6 else -1)


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):
    s = list(map(int, input().split()))
    C.append(s[0])
    A.append(s[1:])

ans = sum(C)
flag2 = True

for i in range(2**N):
    su = [0]*M
    sai = 0
    for j in range(N):
        if ((i >> j) & 1):
            for k in range(M):
                su[k] += A[j][k]
            sai += C[j]
    flag = True
    
    for t in su:
        if t < X:
            flag = False
            break
        else:
            flag2 = False
    if flag:
        if ans > sai:
            ans = sai

if flag2:
    ans = -1

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

N, M, X = list(map(int, input().split()))
C = []
A = []

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

comb_list = []
for i in range(1, N+1):
    comb_list.extend(list(itertools.product(range(N), repeat=i)))
    flag_i = False
    min_cost = 10**7
    for comb in comb_list:
        know = [0] * M
        cost = 0
        for book in comb:

            for i in range(M):
                know[i] += A[book][i]
            cost += C[book]
        
        #達成チェック
        flag = True
        for i in range(M):
            if (know[i] < X):
                flag = False
                
        
        if (flag):
            flag_i = True
            if (min_cost > cost):
                min_cost = cost
    if (flag_i):
        print(min_cost)
        exit(0)

print(-1)

Submission status: Wrong Answer

Solution code:
from itertools import *
n,m,x=map(int,input().split())
L=[list(map(int,input().split())) for _ in range(n)]
a=10**6
for i in range(1,n+1):
    for j in combinations(L,i):
        b=[0]*(m+1)
        for k in j:
            b=[b[i]+k[i] for i in range(m+1)]
        if all(i>=x for i in b[1:]):
            a=min(a,b[0])
print(-1 if a==10**6 else a)

Submission status: Wrong Answer

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

l = [0] * (M+1)
m = []
for x in range(N):
  A = list(map(int, input().split()))
  m.append(A)
  for i, k in enumerate(A):
    l[i] += k

for i, x in enumerate(l):
  if i >= 1:
    if x < X:
      print(-1)
      exit()

m.sort(reverse=True)
#ひいていく
lc = l[:]
for mm in m:
  for i, x in enumerate(mm):
    l[i] -= x
    if i >= 1:
      if l[i] < X:
        l = lc[:]
        break
  lc = l[:]

print(l[0])

Submission status: Wrong Answer

Solution code:
def main():
    import numpy as np
    from itertools import combinations
    n, m, x = map(int, input().split())
    l = [list(map(int, input().split())) for _ in range(n)]

    ans = 10 ** 15
    for i in range(1, m + 1):
        for comb in combinations(l, i):
            y = np.array([x for _ in range(m)])
            tmp = 0
            for p in comb:
                tmp += p[0]
                y -= np.array(p[1:])
            s = sum([j <= 0 for j in y])
            if s == m:
                ans = min(ans, tmp)

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ans = 10**9
for i in range(2**n):
    cost = 0
    an = np.array([0]*m)
    for j in range(n):
        if (i >> j) & 1:
            cost += ca[j][0]
            an = an + np.array(ca[j][1:])
    
    if an[an < x].sum() == 0 and an[0] != 0:
        #print(cost)
        
        ans = min(ans, cost)

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

Submission status: Wrong Answer

Solution code:
mod=1000000007
n,m,x=map(int,input().split())
w=[]
for i in range(n):
    w.append([int(i) for i in input().split()])
ans=mod
for i in range(2**n):
    d=0
    chk=[0]*m
    for j in range(n):
        if (i>>j&1):
            d+=w[j][0]
            for k in range(m):
                chk[k]+=w[j][k+1]

    if min(chk)>=x:
        ans=min(ans,d)
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

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

p_list = list(itertools.product([0,1], repeat=N))
#print((p_list))
cost_min = 10**9
for p in p_list:
  #p = list(p)
  und=[0]*M
  cost = 0
  for i in range(N):
    if p[i]==1:
      cost += tex[i][0]
      for j in range(M):
        und[j]+=tex[i][j+1]
  #print(und)
  f=True
  for k in range(M):
    if und[k]<X:
      f=False
      break
  if f and cost_min>cost:
    cost_min = cost
print(cost_min)

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
ca=[list(map(int,input().split())) for _ in range(n)]
ans=[-1]*m
tmp=[0]*m
for i in range(2**n):
  for j in range(n):
    if (i>>j)&1:
      for k in range(m):
        tmp[k]+=ca[j][k]
  for j in range(1,m):
    if tmp[j]<x:
      break
  else:
    if ans[0]>tmp[0] or ans[0]<0:
      ans=tmp
  tmp=[0]*m
print(ans[0])

Submission status: Wrong Answer

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

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


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

ans = float("inf")
for i in range(1 << N):
    tmp = [0] * M 
    flg = 0
    for j in range(N):
        if (i>>j) & 1:
            for k in range(M):
                tmp[k] += text[j][k]
    for l in range(1, M):
        if tmp[l] < X:
            flg = 1
            break
    if tmp[0] != 0 and not flg:   
        ans = min(ans, tmp[0])    

print(ans if ans != float("inf") else -1)

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:])])


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


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**6
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:
n, m, x = map(int, input().split())
C = {}
ans = 0
sums = [0] * m
for _ in range(n):
    c = [int(x) for x in input().split()]
    C[c[0]] = c[1:]
    ans += c[0]
    for i in range(m):
        sums[i] += c[i + 1]
if min(sums) < x:
    print(-1)
    exit()
C = sorted(C.items(), reverse=True)
for c, A in C:
    sums_ = list(sums)
    minused = True
    for i, a in enumerate(A):
        sums_[i] -= a
        if sums_[i] < x:
            minused = False
            break
    if minused:
        sums = sums_
        ans -= c
print(ans)

Submission status: Wrong Answer

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

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

min_cost = 10**8

for i in range(2**n):
    a = [0] * m
    cost = 0
    for j in range(n):
        if (i >> j) & 1:
            cost += book[j][0]
            for k in range(m):
                a[k] += book[j][k-1]

    valid = True
    for j in range(m):
        if a[j] < x:
            valid = False
            break

    if valid:
        min_cost = min(min_cost, cost)

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

Submission status: Wrong Answer

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

for i in range(2**n):
  count = [0]*m
  for j in range(n):
      if (i >> j) & 1:
        for k in range(m):
          count[k] += lst[j][k]
  judge = True
  for j in range(1, m):
    if count[j] < x:
      judge = False
      break
  if judge:
    ans = min(ans, count[0])
if ans == float('inf'):
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
# Contest No.: ABC167
# Problem No.: C
# Solver:      JEMINI
# Date:        20200510

import sys

def main():
    n, m, x = map(int, sys.stdin.readline().split())
    table = []

    for _ in range(n):
        table.append(list(map(int, sys.stdin.readline().split())))
    for i in range(1, m):
        temp = 0
        for j in range(n):
            temp += table[j][i]
        if temp < x:
            print(-1)
            return
    ans = 0
    for i in range(n):
        ans += table[i][0]
    for i in range(1, 2 ** n):
        temp = i
        cnt = 0
        tempList = [0] * m
        while temp > 0:
            if temp % 2:
                for j in range(m):
                    tempList[j] += table[cnt][j]
            temp >>= 1
            cnt += 1
        flag = True
        for j in range(1, m):
            if tempList[j] < x:
                flag = False
                break
        if flag:
            ans = min(ans, tempList[0])
    print(ans)    
    return

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools
import heapq
#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    n,m,x=map(int,input().split())
    c=[]
    a=[]
    for i in range(n):
        temp=list(map(int,input().split()))
        c.append(temp[0])
        a.append(temp[1:])
    total=INFI
    for i in itertools.product(range(2),repeat=n):
        tempkin=0
        rik=[0 for _ in range(m)]
        for ii in range(n):
            for iii in range(m):
                if i[ii]==1:
                    rik[iii]+=a[ii][iii]
            if i[ii]==1:
                tempkin+=c[ii]
        ans=1
        for j in range(m):
            if rik[j]<x:
                ans=0
                break
        if ans==1:
            total=min(total,tempkin)
    print(total)








if __name__ == "__main__":

    main()

Submission status: Wrong Answer

Solution code:
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N, M, X = map(int, input().split())
    C = [0] * N
    A = []
    for n in range(N):
        s = list(map(int, input().split()))
        C[n] = s[0]
        A.append(s[1:])
    
    res = INF
    for bit in range(2**N):
        tmp = 0
        P = [0] * M
        for n in range(N):
            if (bit >> n) & 1:
                tmp += C[n]
                for m in range(M):
                    P[m] += A[n][m]
        flg = True
        for m in range(M):
            if P[m] < X:
                flg = False
        if flg:
            res = min(res, tmp)

    print(res)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
items = []
for _ in range(N):
    tmps = list(map(int, input().split()))
    price = tmps[0]
    l = tmps[1:]
    items.append((price, l))
n = len(items)
patterns = []
for i in range(2 ** n):
    bag = []
    for j in range(n):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            bag.append(items[j])  # フラグが立っていたら bag に果物を詰める
    patterns.append(bag)
ans = 1000000
for pattern in patterns:
    sum_price = 0
    sum_l = [0 for _ in range(M)]
    for price, l in pattern:
        sum_price += price
        for i in range(M):
            sum_l[i] += l[i]
    check = True
    for i in range(M):
        if sum_l[i] < X:
            check = False
    if check:
        ans = min(ans, sum_price)
if ans ==  1000000:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

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

stk = [0]
eff = [[0] * m]
for i in range(n):
    cost = books[i][0]
    effect = books[i][1:]
    for j in range(len(stk)):
        stk.append(stk[j] + cost)
        tmp = []
        is_ok = True
        for k in range(m):
            tmp.append(effect[k] + eff[j][k])
            if effect[k] + eff[j][k] < x:
                is_ok = False
        if is_ok:
            print(stk[j] + cost)
            exit()
        eff.append(tmp)
print(-1)

Submission status: Wrong Answer

Solution code:
from sys import stdin
from itertools import combinations
N,M,X = [int(x) for x in stdin.readline().rstrip().split()]
data = []
for i in range(N):
    tmp = [int(x) for x in stdin.readline().rstrip().split()]
    data.append(tmp)

ans = 10**18
for i in range(1,N):
    for j in combinations(data,i):
        C = 0
        rikai = [0]*M
        for l in j:
            C += l[0]
            for ind,k in enumerate(l[1:]):
                rikai[ind] += k
        if len([i for i in rikai[:] if i >= X]) == M:
            ans = min(C,ans)
if ans == 10**18:
  ans = -1
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    import numpy as np
    from itertools import combinations
    n, m, x = map(int, input().split())
    l = [list(map(int, input().split())) for _ in range(n)]

    ans = 10 ** 20
    for i in range(1,m+1):
        for comb in combinations(l,i):
            y = np.array([x for _ in range(m)])
            tmp = 0
            for p in comb:
                tmp += p[0]
                y -= np.array(p[1:])
            s = sum([j <= 0 for j in y])
            if s == m:
                ans = min(ans,tmp)

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, M, X = read_ints()
    A = []
    for _ in range(N):
        A.append(read_ints())

    min_T = math.inf
    for S in range(1, (1<<N)):
        T = [0]*M
        for i in range(0, N):
            if (S>>i)&1 == 1:
                for j in range(M):
                    T[j] += A[i][j]
        if all(t >= X for t in T[1:]) and T[0] < min_T:
            min_T = T[0]
    if min_T == math.inf:
        return -1
    return min_T


if __name__ == '__main__':
    print(solve())

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
a=[]
for i in range(n):
  a.append(list(map(int,input().split())))
cursor=n
current=[0]*n
mincost=1000000000000000000000
breakflag=0
while True:
  thing=[0]*m
  cost=0
  for i in range(n):
    if current[i]==1:
      cost+=a[i][0]
      for j in range(m):
        thing[j]+=a[i][j+1]
  success=1
  for j in range(m):
    if thing[j]<x:
      success=0
  if success==1 and cost<mincost:
    mincost=cost
  while True:
    if current[cursor-1]<1:
      current[cursor-1]+=1
      for i in range(cursor,n):
        current[i]=0
      cursor=n
      break
    cursor-=1
    if cursor==0:
      breakflag=1
      break    
  if breakflag==1:
    break
print(mincost)

Submission status: Wrong Answer

Solution code:
import sys
import numpy

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

def main():
    N, M, X = map(int, readline().split())
    cost = []; A = []
    for _ in range(N):
        c, *Atmp = map(int, readline().split())
        cost.append(c); A.append(Atmp)
    cost = numpy.array(cost)
    A = numpy.array(A)

    pay = []
    for i in range(N**2):
        jtmp = []
        costtmp = 0
        for j in range(N):
            if (i>>j)&1:
                jtmp.append(j)
        costtmp = cost[jtmp].sum()
        brain = A[jtmp,:].sum(axis=0)
        if all(brain >= X):
            pay.append(costtmp)

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n , m , x = map(int,input().split())
san = []
for i in range(n):
    san.append(list(map(int,input().split())))
ans = 10**8
for b in range(2**n):
    bs = format(b, 'b')
    bs = str(bs).rjust(n,'0')
    one = 0
    p = [0 for i in range(m)]
    for i in range(n):
        if bs[i] == "1":
            one += san[i][0]
            for j in range(1,m+1):
                p[j-1] += san[i][j]
    if min(p) >= x:
        ans = min(ans,one)
print(ans)

Submission status: Wrong Answer

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

for bit in range(1<<n):
    skills = [0]*m
    yen = 0
    for i in range(n):
        if (bit>>i)&1:
            yen += text[i][0]
            for j in range(m):
                up = text[i][j+1]
                skills[j] += up
    for k in range(m):
        if skills[k] < x:
            break
    else:
        print(yen)
        exit()
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    n, m, x = MII()
    query = [MII() for _ in range(n)]
    mincost = 10**6
    for bit in range(1<<n):
        vals = [0]*m
        cost = 0
        for i in range(n):
            if bit&(1<<i):
                cost += query[i][0]
                for i, c in enumerate(query[i][1:]):
                    vals[i] += c
                x_g = [1 for v in vals if v >= x]
                if sum(x_g) == m:
                    mincost = min(cost, mincost)
    if mincost == 10**6:
        print(-1)
    else:
        print(mincost)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

last_ans = -1
for i in range(1, m+1):
    ans = 10 ** 10
    for j in range(1 << n):
        ans1 = 0
        x1 = 0
        for k in range(n):
            c = books[k][0]
            a = books[k][i]

            if j & (1 << k):
                ans1 += c
                x1 += a
        if x1 >= x:
            ans = min(ans, ans1)

    last_ans = max(last_ans, ans)

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

Submission status: Wrong Answer

Solution code:
def main():
    import numpy as np
    from itertools import combinations
    n, m, x = map(int, input().split())
    l = [list(map(int, input().split())) for _ in range(n)]

    ans = 10 ** 9
    for i in range(1,m+1):
        for comb in combinations(l,i):
            y = np.array([x for _ in range(m)])
            tmp = 0
            for p in comb:
                tmp += p[0]
                y -= np.array(p[1:])
            s = sum([j <= 0 for j in y])
            if s == m:
                ans = min(ans,tmp)

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

if __name__ == '__main__':
    main()