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

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

minyen = float("inf")
for i in range(2**N):
    flag = False
    hoji = []
    rikai = [0]*M
    #print("pattern{}: ".format(i), end="")
    for j in range(M+1):
        if((i>>j)&1):
            hoji.append(hon[j][0])  # フラグが立っていたら bag に果物を詰める
            for k in range(M):
                rikai[k] += hon[j][k+1]

    for k in range(M):
        if X > rikai[k]:
            flag = True
            break

    if flag:
        continue
    else:
        minyen = min(minyen,sum(hoji))

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

Submission status: Wrong Answer

Solution code:
import numpy as np 
from itertools import combinations

n, m, x = [int(i) for i in input().split()]
A = np.array([[int(i) for i in input().split()]for j in range(n)])
cost = n*(10**5)
A_index_set = range(n)
satisfy_flag = False
for L in range(1, n+1):
    for subset in combinations(A_index_set, L):
        ans = np.array([0 for i in range(m+1)])
        for j in subset:
            ans += A[j,:]
        for sub_j in range(1, m+1): # check if everyone is more than x
            if  ans[sub_j] < x:
                break
        else:
            satisfy_flag = True
            cost = min(cost, ans[0])
    if satisfy_flag:
        break
if satisfy_flag:
    print(cost)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
from itertools import combinations

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

ans = 10 ** 9
for i in range(1, n+1):
    combination = combinations(range(n), i)
    for comb in combination:
        init = np.zeros(m+1)
        for ind in list(comb):
            init = init + np.array(lis[ind])
        if np.amin(init) >= x:
            ans = min(ans,init[0])
    if ans < 10**9:
      print(int(ans))
      exit()
      
print(-1,-1,-1)

Submission status: Wrong Answer

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

values = []
for i in range(2**N):
    bags = []
    for j in range(N):
        if ((i >> j) & 1):
            bags.append(j)
    
    value = 0
    algs = [0] * M
    for k in bags:
        value += books[k][0]
        for l in range(M):
            algs[l] += books[k][l]
    
    for r in algs:
        if r < X:
            break
    else:
        values.append(value)
    
if len(values) == 0:
    print(-1)
else:
    print(min(values))

Submission status: Wrong Answer

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

N, M, X = map(int, input().split())
ca = []
for _ in range(N):
  ca.append(list(map(int, input().split())))
  
ns = [i for i in range(N)]
price = 100000000
for r in range(1,N+1):
  for v in itertools.combinations(ns, r):
    aa = []
    flag = True
    for j in range(M):
      s = sum([ca[i][j] for i in v])
      if s < X:
        flag = False
        continue
    if flag:
      p = sum([ca[i][0] for i in v])
      price = min(price, p)
      
if price == 100000000:
  print(-1)
else:
  print(price)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun May 10 21:06:30 2020

@author: shinba
"""
n,m,x = map(int,input().split())

ca = []
for i in range(n):
    ca.append(list(map(int,input().split())))
    
ans = float("inf")
for i in range(1,2**n-1):
    s = [0]*(m+1) 
    for j in range(n):
        if (i>>j) & 1:
            s[0] += ca[j][0]
            for k in range(1,m+1):
                s[k] += ca[j][k]
    if s[0] < ans:
        for i in range(1,m+1):
            if s[i] < x:
                break
        else:
            ans = s[0]

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun May 10 20:50:51 2020
"""

import sys
#import numpy as np
import itertools

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

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

ans = 10 ** 9
for i in range(1,N):
        
    for C in itertools.combinations(ca,i+1):
        tmp = 0
        m = [0 for _ in range(M)]
        for c in C:
            tmp += c[0]
            for i in range(M):
                m[i] += c[1+i]
        flg = True
        for mm in m:
            if mm < X:
                flg = False
        
        if flg:
            ans = min(ans,tmp)

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

Submission status: Wrong Answer

Solution code:
def main():
    from sys import stdin
    import itertools
    n,m,x = map(int,stdin.readline().rstrip().split())
    mat = []
    for _ in range(n):
        temp = list(map(int,stdin.readline().rstrip().split()))
        mat.append(temp)
    
    sum = []
    for i in range(n):
        for l in itertools.combinations(mat,i):
            temp = [0]*m
            for j in l:
                for k in range(m):
                    temp[k]+=j[k]
            sum.append(temp)
    
    sum.sort(key=lambda x: x[0])
    for l in sum:
        ans = -1
        flag = True
        for j in l[1:]:
            if j < x:
                flag = False
                break
        
        if flag:
            ans=l[0]
            break
    
    print(ans)
main()

Submission status: Wrong Answer

Solution code:
cin = open(0).read().strip().split('\n')
n,m,x = map(int, cin[0].split(' '))
books = []
for i in cin[1:]:
    books.append(tuple(map(int, i.split(' '))))

money = float('inf')
for i in range(2**n):
    ret = [0] * m
    tmp_money = 0
    for j in range(n):
        if i >> j & 1:
            for mi in range(m):
                ret[mi] += books[j][1+mi]
            tmp_money += books[j][0]
    if min(ret) >= x:
        money = min(money, tmp_money)
        break
if money == float('inf'):
    print(-1)
else:
    print(money)

Submission status: Wrong Answer

Solution code:
# C - Skill Up

import itertools
import numpy as np
N, M, X = map(int, input().split())
CA = np.zeros((N, M+1), dtype=np.int64)
for i in range(N):
    CA[i] = list(int(x) for x in input().split())

ans = 10**18
for lst in itertools.product((0,1), repeat=N):
    tmp = 0
    pnt = np.zeros(M, dtype=np.int8)
    for i in range(N):
        if lst[i] == 1:
            tmp += CA[i][0]
            pnt += CA[i][1:]
            if np.all(pnt >= X):
                ans = min(ans, tmp)

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

Submission status: Wrong Answer

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

q = set()
q.add(tuple([0] * (m+1)))

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

    update = set()
    for qq in q:
        l = list(qq)
        l[0] = qq[0] + c[0]
        for i in range(1, m+1):
            l[i] = min(qq[i] + c[i], x)
        update.add(tuple(l))

    q.update(update)

max_ans = 10 ** 5 * 12
ans = max_ans
for qq in q:
    if qq[0] < ans and sum(qq[1:]) == m * x:
        ans = qq[0]

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# vim: set fileencoding=utf-8

# pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation


"""Module docstring
"""

import functools
import heapq
import itertools
import logging
import math
import random
import string
import sys
from argparse import ArgumentParser
from collections import defaultdict, deque
from copy import deepcopy
from typing import Dict, List, Optional, Set, Tuple

MAX = 12 * pow(10, 5)


def solve(
    prices: List[int], values: List[List[int]], target: int, rows: int, cols: int
) -> Optional[int]:
    min_price = MAX
    for i in range(rows):
        for picked in itertools.combinations(range(rows), i + 1):
            for j in range(cols):
                if sum(values[k][j] for k in picked) < target:
                    break
            # for else
            else:
                min_price = min(min_price, sum(prices[k] for k in picked))
    return min_price if min_price < MAX else None
    # dp[i] = (p, l) min price p to get to level l (max target)
    dp = [[(0, 0)] * cols for _ in rows]
    for i in range(rows):
        pi = prices[i]
        vi = values[i]
        dp = []
        for j in range(cols):
            if l < target:
                dp.append((pi + p, l + vi[j]))
    return target


def do_job():
    "Do the work"
    LOG.debug("Start working")
    # first line is number of test cases
    N, M, X = map(int, input().split())
    values = []
    prices = []
    for _ in range(N):
        p, *v = map(int, input().split())
        assert len(v) == M
        prices.append(p)
        values.append(v)
    result = solve(prices, values, X, N, M)
    print(result if result else -1)


def print_output(testcase: int, result) -> None:
    "Formats and print result"
    if result is None:
        result = "IMPOSSIBLE"
    print("Case #{}: {}".format(testcase + 1, result))
    # 6 digits float precision {:.6f} (6 is the default value)
    # print("Case #{}: {:f}".format(testcase + 1, result))


def configure_log() -> None:
    "Configure the log output"
    log_formatter = logging.Formatter("%(lineno)d - " "%(message)s")
    handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(log_formatter)
    LOG.addHandler(handler)


LOG = None
# for interactive call: do not add multiple times the handler
if not LOG:
    LOG = logging.getLogger("template")
    configure_log()


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    parser = ArgumentParser()
    parser.add_argument(
        "-v",
        "--verbose",
        dest="verbose",
        action="store_true",
        default=False,
        help="run as verbose mode",
    )
    args = parser.parse_args(argv)
    if args.verbose:
        LOG.setLevel(logging.DEBUG)
    do_job()
    return 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    sys.exit(main())


class memoized:
    """Decorator that caches a function's return value each time it is called.
    If called later with the same arguments, the cached value is returned, and
    not re-evaluated.
    """

    def __init__(self, func):
        self.func = func
        self.cache = {}

    def __call__(self, *args):
        try:
            return self.cache[args]
        except KeyError:
            value = self.func(*args)
            self.cache[args] = value
            return value
        except TypeError:
            # uncachable -- for instance, passing a list as an argument.
            # Better to not cache than to blow up entirely.
            return self.func(*args)

    def __repr__(self):
        """Return the function's docstring."""
        return self.func.__doc__

    def __get__(self, obj, objtype):
        """Support instance methods."""
        return functools.partial(self.__call__, obj)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import itertools

def main():
    N, M, X = map(int, input().split())
    C = [0] * N
    A = []
    for n in range(0, N):
        l = input().split()
        C[n] = int(l[0])
        A.append([int(i) for i in l[1:]])
        print(C[n], A[n])

    min_cost = sum(C) + 1
    for i in range(N):
        for comb in itertools.combinations(range(N), i):
            canAchive = True
            for m in range(M):
                r = 0
                for n in comb:
                    r += A[n][m]
                if (r < X):
                    canAchive = False
                    break
            if (canAchive):
                cost = sum([C[n] for n in comb])
                min_cost = min(min_cost, cost)

    if (min_cost <= sum(C)):
        print(min_cost)
    else:
        print(-1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
k=[0]*m
ans=0
e=0
for i in range(m):
  for c in range(n):
    k[i]+=l[c][i+1]
for i in range(n):
  ans+=l[i][0]
d=[]
for q in range(n,0,-1):
  d.append(l[q-1])
for i in range(n):
  e=0
  for p in range(m):
    if k[p]-d[i][p+1]<x:
      break
    else:
      e+=1
  if e==m:
    for u in range(m):
      k[u]-=d[i][u+1]
    print(ans)
    ans-=d[i][0]
print(ans)

Submission status: Wrong Answer

Solution code:
import sys 
try:
	sys.stdin = open('Input.txt', 'r') 
	sys.stdout = open('Output.txt', 'w')
except:
	pass

input = sys.stdin.readline

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

for i in range(n):
	l = list(map(int,input().split()))
	books.append(l)

costfinal = float('inf')
for i in range(n):
	cost = books[i][0]
	threshold = books[i][1:]
	# print(cost,threshold)
	for k in threshold:
		if k<x:
			break
	else:
		costfinal = min(costfinal,cost)
			
	for j in range(i+1,n):
		cost += books[j][0]
		for k in range(m):
			threshold[k] += books[j][k+1]
		# print("  ",cost,threshold)

		for k in threshold:
			if k<x:
				break
		else:
			costfinal = min(costfinal,cost)

if costfinal!=float('inf'):
	print(costfinal)
else:
	print(-1)

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):
    use = format(i,"0{}b".format(N))
    print(use)
    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:
n,m,x = map(int,input().split())
s = []
mini = 10**9
for i in range(n):
    s.append(list(map(int,input().split())))
for i in range(2**n):
    l = [0]*m
    flag = 0
    for j in range(n):
        if ((i>>j) & 1):
            for k in range(m):
                l[k] += s[j][k]
    for check in l:
        if check < x:
            flag = 1  
    if flag == 0:
        mini = min(mini, l[0])
if (mini==10**9):print(-1)
else: print(mini)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
import numpy as np
N, M, X = map(int, input().split())
xx = np.array([X for _ in range(M)])

C = {}
costs = []
for _ in range(N):
    c, *A = map(int, input().split())
    C[c] = A
    costs.append(c)
ans = 10**9
for i in range(1, N+1):
    for comb in combinations(costs, i):
        tmp = 0
        x = xx.copy()
        for cost in comb:
            tmp += cost
            x -= np.array(C[cost])
        if len(x[x <= 0]) == M:
            ans = min(ans, tmp)

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

Submission status: Wrong Answer

Solution code:
def sum_list(l1, l2):
  return [i+j for i, j in zip(l1, l2)]

def judge(l):
  for i in l:
    if i < X:
      return False
  return True

N, M, X = map(int, input().split())
array = []
zeros = [0]*M
for i in range(N):
  row = [j for j in map(int, input().split())]
  array.append(row)
  zeros = sum_list(zeros, row)

for z in zeros[1:]:
  if z < X:
    print(-1)
    exit()

ret = float('inf')
for i in range(2**N):
  arr = [0]*M
  cost = 0
  for j in range(N):
    if i >> j & 1:
      arr = sum_list(arr, array[j])
  if judge(arr):
    ret = min(ret, arr[0])
    
print(ret)

Submission status: Wrong Answer

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

MAX = 10**5 * 12 + 1

for i in range(1, N + 1):
    min_ = MAX
    for cas in combinations(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:
import sys,copy

N,M,X = list(map(int,input().split()))
C = [list(map(int,input().split())) for i in range(N)]
C.sort(key=lambda x: x[0],reverse = True)

total = [0]*(M+1)
for c in C:
    total = [x + y for (x,y) in zip(total,c)]

def j(l):
    flg=0
    for r in l:
        if r < X:
            flg=1
    if flg==1:
        return False
    else:
        return True

if j(total[1:])== False:
    print(-1)
    sys.exit()

for i,c in enumerate(C):
    min = [x - y for (x,y) in zip(total,c)]
    if j(min):
        total = copy.copy(min)

if j(min):
    print(min[0])
else:
    print(total[0])

Submission status: Wrong Answer

Solution code:
import sys
import itertools
sys.setrecursionlimit(10**6)

INF = 10**10


def main(input, print):
    n, m, x = map(int, input().split())
    table = [[] for _ in range(n)]
    for i in range(n):
        table[i] = list(map(int, input().split()))
    ans = INF
    for i in range(1, n):
        p = itertools.permutations(range(n), i)
        for pj in p:
            t = 0
            mt = [0] * m
            for k in range(len(pj)):
                t += table[pj[k]][0]
                for l in range(m):
                    mt[l] += table[pj[k]][l+1]
            is_ok = True
            for l in range(m):
                if mt[l] < x:
                    is_ok = False
            if is_ok:
                ans = min(ans, t)
    if ans == INF:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main(sys.stdin.readline, print)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M, X = map(int, input().split(' '))
C = []
A = []
for i in range(N):
    c, *a = map(int, input().split(' '))
    C.append(c)
    A.append(np.array(a))

ans = np.inf

for i in range(2**N):
    point = np.zeros(M)
    cost = 0

    for j in range(N):
        if ((i >> j) & 1):
            point += A[j]
            cost += C[j]

    if np.all(point >= X):
        print(point)
        ans = min(ans, cost)

if ans != np.inf:
    print(ans)
else:
    print('-1')

Submission status: Wrong Answer

Solution code:
from itertools import combinations, chain

def main():
    n,m,x = map(int, input().split())
    books = [list(map(int, input().split())) for _ in range(n)]
    comb = [*chain(*(combinations(books, n+1) for n in range(len(books))))]
    print(comb)
    money = 10**9
    for c in comb:
        c = c[0]
        s = sum([c[i] for i in range(1,m+1)])
        if s < x:
            break
        money = min(money,sum(c[0] for _ in c))
    if money == 10**9:
        money = -1
    print(money)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from itertools import combinations

N, M, X = list(map(int,input().split()))
A = []
for i in range(N):
  A.append(list(map(int,input().split())))
sum = []
subsets=[]
for i in range(len(A) + 1):
    for c in combinations(A, i):
        subsets.append(list(c))

subsets = subsets[1:]
for i in subsets:
  tmp = [0]*6
  if len(i) == 1:
    sum.append(i[0])
  else:
    for j in i:
      tmp = list(map(lambda a,b: a + b, tmp,j))
    sum.append(tmp)
    
min_price = 1000000

for i in sum:
  t = 0
  for j in i:
    if X > j:
      t = 1
  if t == 0:
    min_price = min(min_price, i[0])

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m,x=map(int,input().split())
ans=10**5
f=1
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)
    f=0
if f:
  print(-1)
else:
  print(int(ans))

Submission status: Wrong Answer

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

def tas(l1,l2):
    l3=[]
    for i in range(m+1):
        l3.append(l1[i]+l2[i])
    return l3


ll=[[0 for i in range(m+1)]]
for i in range(n):
    for j in range(len(ll)):
        ll.append(tas(ll[j],l[i]))

lm=[]
for i in ll:
    lll=[]
    for j in i:
        if j>=x:
            lll.append(True)
        else:
            lll.append(False)
    if all(lll)==True:
        lm.append(i[0])

if len(lm)>0:
    print(min(lm))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
s = []
mini = 10**9
for i in range(n):
    s.append(list(map(int,input().split())))
for i in range(2**n):
    l = [0]*m
    flag = 0
    for j in range(n):
        if ((i>>j) & 1):
            for k in range(m):
                l[k] += s[j][k]
    for check in l:
        if check < x:
            flag = 1  
    if flag == 0:
        mini = min(mini, l[0])
print(mini)

Submission status: Wrong Answer

Solution code:
from itertools import product

N, M, X = [int(x) for x in input().strip().split(" ")]
C = []
A = []

for _ in range(N):
    v = [int(x) for x in input().strip().split(" ")]
    c = v.pop(0)
    C.append(c)
    A.append(v)

sums = []
patterns = product(*[(0, 1) for _ in range(N)])
for pattern in patterns:
    price = 0
    print(pattern)
    status = [0 for _ in range(M)]
    for i, p in enumerate(pattern):
        price += C[i] * p
        for j in range(M):
            status[j] += A[i][j] * p
    if min(status) >= X:
        sums.append(price)

if len(sums) > 0:
    print(min(sums))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
N, M, X = [int(_) for _ in input().split()]
B = []
for i in range(N):
    B.append([int(_) for _ in input().split()])

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

U = [0 for i in range(M)]
money = 0
for b in B:
    for i in range(M):
        U[i] += b[i+1]
    money += b[0]

if min(U) < X:
    print(-1)
else:
    for b in B:
        for i in range(M):
            if U[i] - b[i+1] < X:
                break
        else:
            for i in range(M):
                U[i] -= b[i+1]
            money -= b[0]
    print(money)

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
ca=[]
sum=[]
ans=float('inf')
for _ in range(n):
    ca.append(list(map(int,input().split())))
for i in range(2**n):
    money=0
    check=[0]*(m-1)
    for j in range(n):
        if ((i>>j)&1):
            money+=ca[j][0]
            for k in range(m-1):
                check[k]+=ca[j][k+1]
    if all(check[p]>=x for p in range(m-1)):
        ans=min(ans,money)
if ans==float('inf'):
    print('-1')
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
import numpy as np


def main():
    n, m, x = list(map(int, input().split()))
    A = np.array([list(map(int, input().split())) for _ in range(n)])
    cost = []
    for i in range(n):
        combs = combinations(range(n), i+1)
        for comb in combs:
            A2 = np.array([A[c] for c in comb])
            A2sum = np.sum(A2, axis=0)
            if (A2sum[1:] >= x).all():
                cost.append(A2sum[0])
        if len(cost) > 0:
            print(min(cost))
            break
    else:
        print(-1)




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy
N,M,X=map(int,(input().split()))
book=[]
for i in range(N):
  book.append(list(map(int,(input().split()))))
row_sum = numpy.sum(book, axis=0)
if(min(row_sum)<X):
  print("-1")

Submission status: Wrong Answer

Solution code:
import numpy as np 
from itertools import combinations

n, m, x = [int(i) for i in input().split()]
A = np.array([[int(i) for i in input().split()]for j in range(n)])
cost = n*(10**5)
A_index_set = range(n)
satisfy_flag = False
for L in range(1, n+1):
    for subset in combinations(A_index_set, L):
        ans = np.array([0 for i in range(m+1)])
        for j in subset:
            ans += A[j,:]
        for sub_j in range(1, m): # check if everyone is more than x
            if  ans[sub_j] < x:
                break
        else:
            satisfy_flag = True
            cost = min(cost, ans[0])
    if satisfy_flag:
        break
if satisfy_flag:
    print(cost)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
N,M,X = map(int,input().split())
CA = [list(map(int,input().split())) for _ in range(N)]
def judge(books):
    study = [0]*(M+1)
    money = 0
    for i in range(N):
        if(books[i] == "1"):
            for j in range(M):
                study[j] += CA[i][j]
            money += CA[i][0]
    for i in range(M):
        if(study[i] < X):
            return -1
    return money
ans = 10**10
for i in range(0,2**N):
    books =  str('{:0100b}'.format(i))[100-N:]
    tmp = judge(books)
    if(tmp == -1):
        continue
    ans = min(judge(books),ans)
if(ans == 10**10):
    print("-1")
else:
    print(ans)

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**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 = []
a = []
for i in range(n):
    row = list(map(int, input().split()))
    c.append(row[0])
    a.append(row[1:])

import itertools

ans = float('inf')
for r in range(n):
    for idxs in itertools.combinations(range(n), r=r):
        price = [0]*m
        for idx in idxs:
            for i in range(m):
                price[i] += a[idx][i]
        
        if all(price[i] >= x for i in range(m)):
            ans = min(ans, sum(c[idx] for idx in idxs))

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

Submission status: Wrong Answer

Solution code:
from itertools import combinations
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 combinations(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:
import numpy as np

N, M, X = map(int, input().split())
CA = []
for _ in range(N):
    Ci, *A = map(int, input().split())
    CA.append((Ci, A))

ans = 10**6
studied = np.array([0] * M)

for i in range(2**N):
    flag = True
    tmp_ans = 0
    studied = np.array([0] * M)
    for j in range(N):
        if i >> j & 1:
            tmp_ans += CA[j][0]
            studied += CA[j][1]
    for study in studied:
        if study < X:
            flag = False
            break
    if flag:
        ans = min(ans, tmp_ans)

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

Submission status: Wrong Answer

Solution code:
import numpy
N,M,X=map(int,(input().split()))
book=[]
for i in range(N):
  book.append(list(map(int,(input().split()))))
row_sum = numpy.sum(book, axis=0)
if(min(row_sum<X)):
  print("-1")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun May 10 20:50:51 2020
"""

import sys
#import numpy as np
import itertools

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

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

ans = 10 ** 9
for i in range(1,N):
        
    for C in itertools.combinations(ca,i):
        tmp = 0
        m = [0 for _ in range(M)]
        for c in C:
            tmp += c[0]
            for i in range(M):
                m[i] += c[1+i]
        flg = True
        for mm in m:
            if mm < X:
                flg = False
        
        if flg:
            ans = min(ans,tmp)

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

Submission status: Wrong Answer

Solution code:
import copy
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:])

# print(c, a)
ans = 10**10

def isClear(arr):
    return all(val >= x for val in arr)

def solve(idx, price, arr):
    global ans
    if idx == n:
        if isClear(arr):
            # print('clear:', arr)
            ans = min(ans, price)
        return

    # Read
    temp = copy.deepcopy(arr)
    for i in range(m):
        temp[i] += a[idx][i]

    solve(idx + 1, price + c[idx], temp)

    # Not read
    solve(idx + 1, price, arr)

score = [0]*m
solve(0, 0, score)

print(ans)