Problem:


Score : 300 points

Problem

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

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

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

Constraints

All values in input are integers.

1\leq N, M\leq 12

1\leq X\leq 10^5

1\leq C_i \leq 10^5

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

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

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

Sample Output 1

120

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

Sample Input 2

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

Sample Output 2

-1

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

Sample Input 3

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

Sample Output 3

1067



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


Sample output:
120

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np
n, m, x = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]
l = np.array(l)
ans = np.sum(l, 0)[0]
ans_s = np.sum(l, 0)
if np.any(ans_s[1:] < x):
    print(-1)
    exit()
count = 0
for i in range(1, n + 1):
    for j in itertools.permutations(l, i):
        tot = np.sum(j, 0)
        if np.all(tot[1:] >= x) and tot[0] < ans:
            ans = tot[0]
            count += 1
    if count == 1:
        break
print(int(ans))

Submission status: Wrong Answer

Solution code:
import 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[1:]):
        total = copy.copy(min)

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

Submission status: Wrong Answer

Solution code:
import itertools
import sys
import numpy as np

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

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


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


min_value = sys.maxsize
for r in result:
    print(r)
    if ex(r):
        min_value = min(min_value, r[0])
print(min_value) if min_value != sys.maxsize else print(-1)

Submission status: Wrong Answer

Solution code:
import itertools

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

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

ans = []
for i in range(n):
    for combination in list(itertools.combinations(range(n), i)):
        #print(combination)
        total = 0
        li = [0] * m
        for j in combination:
            total += C[j]
            for k in range(m):
                li[k] += A[j][k]
        flag = True
        for l in range(m):
            if li[l] < x:
                flag = False
        if flag:
            ans.append(total)
if len(ans) == 0:
    print(-1)
else:
    print(min(ans))

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
A, C = [], []
for _ in range(N):
    tmp = input().split()
    C.append(int(tmp[0]))
    A.append([int(i) for i in tmp[1:]])
is_clear = False
min_cost = 99999999999
for i in range(2 ** N - 1):
    flgs = format(i, '0'+str(N)+'b')
    thr = [X] * M
    cost = 0
    for j in range(N):
        if flgs[j] == '1':
            cost += C[j]
            for k in range(M):
                thr[k] -= A[j][k]
    is_all_clear = True
    for k in range(M):
        if thr[k] > 0:
            is_all_clear = False
            break
    if is_all_clear:
        is_clear = True
        if min_cost > cost:
            min_cost = cost
if is_clear:
    print(min_cost)
else:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools

def get_target_list(source):
    targets = []
    for size in range(1, len(source) + 1):
        for x in itertools.combinations(source, size):
            targets.append(x)
    return targets

paramN, paramM, paramX = list(map(lambda x: int(x), input().split(' ')))
targets = get_target_list([list(map(lambda x: int(x), input().split(' '))) for i in range(paramN)])

price_sum = 100000000
for books in targets:
    ps = 0
    tmp = [i for i in range(paramM)]
    for book in books:
        ps += book[0]
        for i, x in enumerate(book[1:]):
            tmp[i] += x
    if len(list(filter(lambda y: y < paramX, tmp))) == 0:
        price_sum = min(price_sum, ps)

if price_sum == 100000000:
    print(-1)
else:
    print(price_sum)

Submission status: Wrong Answer

Solution code:
import itertools

books = {}
name = 1
N,M,X = map(int, input().split())
for i in range(N):
    book = [int(i) for i in input().split()]
    books[name] = book
    name += 1

choices = []
for i in range(len(books.keys())):
    for j in itertools.combinations(books.keys(), i):
        choices.append(j)
choices = choices[1:]

prizes = []
for choice in choices:
    # print(choice)
    prize = 0
    score = [0]*M
    for num in choice:
        prize += books[num][0]
        score = [score[i]+books[num][i+1] for i in range(0,len(score))]
    # print(score)
    # print(min(score))
    if X<=min(score): 
        prizes.append(prize)
    # print('----')
if len(prizes) != 0: print(min(prizes))
else: print('-1')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools

n,m,x=[int(i) for i in input().split(" ")]
l=[]
for i in range(n):
    l.append([int(i) for i in input().split(" ")])

l.sort()

ans=[]

if x==0:
    ans.append(0)

for i in range(1,n+1):
    for pair in itertools.combinations(l,i):
        sumL=[0]*m
        for p in pair:
            for j in range(m):
                sumL[j]+=p[j+1]
        flag=True
        for j in range(m):
            if sumL[j]<x:
                flag=False
                break
        if flag:
            ans.append(sum([i[0] for i in pair]))

            break

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

Submission status: Wrong Answer

Solution code:
def main():
    n,m,x = map(int, input().split())
    c = [list(map(int, input().split())) for _ in range(n)]
    c = sorted(c, key=lambda x:(sum(x[1:])/m)/x[0], reverse=True)
    ans = 0
    rikaido = [0]*m
    possible = False
    for i in c:
        ans += i[0]
        for num, val in enumerate(i[1:]):
            rikaido[num] += val
        if min(rikaido) >= x:
            possible = True
            break
    print(ans) if possible else print(-1)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

if __name__ == '__main__':
    T = input().split()
    N = int(T[0])
    M = int(T[1])
    X = int(T[2])
    price = np.zeros(N)
    qual = np.zeros((N, M))
    for n in range(N):
        t = input().split()
        price[n] = int(t[0])
        qual[n, :] = np.array([int(m) for m in t[1:]])

    ind = np.argsort(np.sum(qual, axis=1) / price)[::-1]
    sums = np.cumsum(qual[ind, :], axis=0)
    if np.any(sums[-1, :] < X):
        print(-1)
    else:
        pay = 0
        for i in range(N):
            pay += price[ind[i]]
            if np.all(sums[i, :] >= X):
                print(int(pay))
                break

Submission status: Wrong Answer

Solution code:
def main():
    IN1 = [int(_) for _ in input().split()]
    N = IN1[0]
    M = IN1[1]
    X = IN1[2]
    AC = [[int(_) for _ in input().split()] for i in range(N)]

    minSum = 100001
    for i in range(2 ** N):
        tmpSum = 0
        tmpA = [0] * M
        for j in range(N):
            if ((i >> j) & 1):
                tmpSum = tmpSum + AC[j][0]
                for k in range(1, M + 1):
                    tmpA[k-1] = tmpA[k-1] + AC[j][k]

        result = True
        for a in tmpA:
            if a < X:
                result = False
        if result:
            if minSum >= tmpSum:
                minSum = tmpSum

    if minSum != 100001:
        print(minSum)
        return
    print("-1")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import itertools as it

n,m,x=map(int, input().split())
l=[]
check=[0]*(m)
ans=0
for i in range(n):
    a=list(map(int, input().split()))
    ans+=a[0]
    for j in range(m):
        check[j]+=a[j+1]
    l.append(a)

if min(check)<x:
    print('-1')
    exit()


for i in range(1,n+1):
    for p in it.combinations(range(n), i):
        print(p)
        mon=0
        che=[0]*m
        for j in range(len(p)):
            mon+=l[p[j]][0]
            for k in range(m):
                che[k]+=l[p[j]][k+1]
        #print(che)
        if min(che)>=x:
            ans=min(ans,mon)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n, m, x = list(map(int, input().split()))
a = [list(map(int,input().split())) for l in range(n)]
x_list = [x]*m
s = range(2**n)
ans = 10**5
count = 0
for i in s:
    y = np.zeros(m+1)
    for j in range(n):
        if ((i>>j)&1):
            y = y+np.array(a[j])
    if np.all(np.array(y[1:])>=np.array(x_list)):
        count = 1
        ans = min(ans, y[0])  

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

Submission status: Wrong Answer

Solution code:
import itertools

N, M, X = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(N)]
list_N = [i for i in range(N)]

ans = []
for num_book in range(1, N + 1):
    for i in itertools.combinations(list_N, num_book):
        #print(i)
        temp = 0
        for j in range(1, M + 1):
            sum_line = sum([s[i[k]][j] for k in range(num_book)])
            if sum_line < X:
                break
            temp += 1
            if temp == M:
                score=sum([s[i[k]][0] for k in range(num_book)])
                #print(score)
                ans.append(score)
    #if len(ans) != 0:
    #    break
if len(ans)==0:
    print(-1)
else:
    print(ans)
    print(min(ans))

Submission status: Wrong Answer

Solution code:
import itertools

p = list(map(int,input().split()))
N = p[0]
M = p[1]
X = p[2]

l = [[int(i) for i in input().split()] for j in range(N)]

hoge = []
kouho = list(range(1,N+1))
for i in itertools.combinations_with_replacement(kouho, N):
    hoge.append(list(set(i)))

hoge = list(map(list, set(map(tuple, hoge))))
last_val = 100001
flag = False

for ls in hoge:
    ls = list(set(ls))
    ans = [0] * M
    val = 0
    for a in ls:# a = [1,2]ながさM
        for ix,i in enumerate(l[a-1][1:]):
            ans[ix] += i
        val += l[a-1][0]
    b = [i for i in ans if i >= X]
    if len(b) == len(ans):
        last_val = min(last_val, val)
        flag = True

if flag:
    print(last_val)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M, X = map(int, input().split())

D = np.array([])
for i in range(N):
    D = np.append(D,list(map(int, input().split())))
D = D.reshape(N,M+1)

S = D.sum(axis=0)

if all(s >= X for s in S[1:]):
    D = D[np.argsort(D[:, 0])[::-1]]
    for i in range(N):
        newS = S - D[i]
        if all(j>=X for j in newS[1:]):
            S = newS
    print(int(S[0]))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n,m,x = list(map(int,input().split()));
price = [0]*n;
rikai = [[0]*m for i in range(n)];

for i in range(n) :
    ca = list(map(int,input().split()));
    price[i] = ca[0];
    for j in range(m) :
        rikai[i][j] = ca[j+1];

ans = sum(price);
able = 0;
for i in range(2**n) :
    allrikai = [0]*m;
    nowprice = 0;
    for j in range(n) :
        if (i>>j)&1 :
            nowprice += price[j];
            for k in range(m) :
                allrikai[k] += rikai[j][k];
    check = 1;
    for j in range(m) :
        if allrikai[j] < x :
            check = 0;
            break;
    if check and nowprice < ans :
        able = 1;
        ans = nowprice;

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

Submission status: Wrong Answer

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

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main(N,M,X,C, A):
    min_cost = ''
    combs = set()
    for i in range(N):
        for c in combinations(range(N), i):
            combs.add(c)

    for comb in combs:
        cost = 0
        xs = [0 for _ in range(M)]
        for c in comb:
            for i in range(M):
                xs[i] += A[c][i]
            cost += C[c]

        if all([x>=X for x in xs]):
            min_cost = cost if min_cost =='' else min(min_cost, cost)

    if min_cost != '':
        print(min_cost)
    else:
        print(-1)

    pass

if __name__ == '__main__':
    C = []
    A = []
    N, M, X = list(map(int, input().split()))
    for n in range(N):
        lst = list(map(int, input().split()))
        # for m in range(M):
        
        c = lst[0]
        a = lst[1:]

        C.append(c)
        A.append(a)

    
    main(N,M,X,C, A)

Submission status: Wrong Answer

Solution code:
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import sympy as syp(素因数分解とか)
Mod = 1000000007
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    n, m, x = map(int, input().split())
    ca = [list(map(int, input().split())) for i in range(n)]
    c = [[ca[i][0],i] for i in range(n)]
    a = [ca[i][1:] for i in range(n)]
    ans = float("inf")
    subsc = []#選ばれている本
    for i in range(1 << n):
        for j in range(n):
            if (i >> j)&1:
                subsc.append(ca[j])
        flag = True
        cost = 0
        if len(subsc) == 0:
            continue
        unst = 0  #理解度
        for j in range(1,m):
            for k in range(len(subsc)):
                unst += subsc[k][j]
            if unst < x:
                flag = False
                unst = 0
        for j in range(len(subsc)):
            cost += subsc[j][0]
        if flag:
            ans = min(ans, cost)
        flag = True
        cost = 0
        subsc = []
    if ans == float("inf"):
        ans = -1
    print(ans)

if __name__ == "__main__":
    main() #endline===============================================

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:






def     process(tab, tour, current, result,skill, N, M, X):
    finish = True
    for i in skill:
        if (i < X):
            finish = False
            break
    if (finish):
        if (result == -1):
            return current
        else:
            return min(result, current)
    if (tour == N or (current > result and result > -1)):
        return result

    current += tab[tour][0]
    for i in range(1, M+1):
        skill[i-1] += tab[tour][i]
    avec = process(tab, tour + 1, current, result, skill, N, M, X)
    
    if (result == -1 or (avec < result and avec > -1)):
        result = avec
    current -= tab[tour][0]
    for i in range(1, M):
        skill[i-1] -= tab[tour][i]
    sans = process(tab, tour + 1, current, result, skill, N, M, X)
    
    if (result == -1 or (sans < result and sans > -1)):
        result = sans
    return result


data = input().split()
n,m,x = int(data[0]), int(data[1]), int(data[2])


tab = []
for i in range (n):
    data = input().split()
    t = []
    for j in range (m+1):
        t.append(int(data[j]))
    tab.append(t)


skill = [0] * m
result = process(tab, 0, 0, -1, skill, n,m,x)
print(result)

Submission status: Wrong Answer

Solution code:
N, M, X = [int(x) for x in input().split()]


C = []
RIKAI = []
ans = 0

#buy = 0b000000001000
#print(buy)

BOOK= []
for i in range(N):
    BOOK += [[int(x) for x in input().split()]]

ans = -1
MIN_PAY = 10**5 * 12

for FLAG in range(2 ** N ):
    PAY = 0
    RIKAI = [0] * M
    for i in range(N):
        if FLAG >> i & 1:
            for j in range(M):
                RIKAI[j] = RIKAI[j] + BOOK[i][j+1]
            PAY += BOOK[i][0] 
    if min(RIKAI) >= X:
        MIN_PAY = min(PAY,MIN_PAY)
        

if MIN_PAY == 10 ** 5 * 12:
    ans = -1
else:
    ans = MIN_PAY

print(ans)

Submission status: Wrong Answer

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

cost_list = []
for choice in range(n+1):
  for v in itertools.combinations(ca, choice):
    cost = 0
    us = [0] * m
    for t in v:
      cost += t[0]
      for i in range(m):
        us[i] += t[i+1]
    flag = True
    for check in range(m):
      if us[check] < x:
        flag = False
    if flag == True:
      cost_list.append(cost)
    print(cost, us, cost_list)

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

Submission status: Wrong Answer

Solution code:
N, M, X = map(int,input().split())
sum_list = [0]*(M+1)
CA = []
for i in range(N):
    a = list(map(int,input().split()))
    CA.append(a)
    for j in range(M+1):
        sum_list[j] += a[j]

CA.sort(reverse = True)#高い順にべる
ans = sum_list[0]

for ca in CA:
    for j in range(1,M+1):
        if sum_list[j] - ca[j] < X:
            break
            break
        else:
            sum_list[j] -= ca[j]
            if j == M:
                ans -= ca[0]

#そもそも足りていないとき
for t in sum_list[1:M+1]:
    if t < X:
        ans = -1
        break

print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import combinations

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

    row = []

    ans = 10 ** 10

    for i in range(N):
        row.append(list(map(int, input().split())))

    for k in range(1, N+1):
        co = list(combinations(row, k))

        for t in co:
            cost = 0
            skill = [0] * M
            for v in t:
                cost += v[0]
                for s in range(M):
                    skill[s] += v[s+1]

            if(min(skill) >= X):
                ans = min(ans, cost)

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np

N, M, X = map(int, input().split(' '))
S = [0]*N

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


for i in range(1, N+1):
  C = list(itertools.combinations(S, i))
  C = np.array(C)
  C = np.array([sum(c) for c in C])
  C = C[np.argsort(C[:, 0])]
  
  for c in C:
    if np.all(c[1:] >= X):
      print(c[0])
      exit()

print(-1)

Submission status: Wrong Answer

Solution code:
def m():
    N, M, X = map(int, input().split())
    CA = [list(map(int, input().split())) for _ in range(N)]
    ans = float('inf')
    for i in range(2 ** N):
        b = bin(i)[2:]
        b = b.zfill(N)
        tmp = [0] * (M + 1)
        for j, v in enumerate(b):
            if v == '0':
                continue
            tmp[0] += CA[j][0]
            for k in range(1, M + 1):
                tmp[k] += CA[j][k]
        f = 1
        for p in range(1, M):
            if tmp[p] < X:
                f = 0
                break
        if f == 0:
            continue
        ans = min(ans, tmp[0])
    if ans == float('inf'):
        return '-1'
    else:
        return ans


print(m())

Submission status: Wrong Answer

Solution code:
import numpy as np

n,m,x=map(int,input().split())
li=[list(map(int,input().split())) for i in range(n)]
li=np.array(li)
y=np.sum(li, axis=0)
if(np.min(y[1:])<x):
    print(-1)

for i in range(n):
    for j in range(n):
        pass

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools
import sys
N,M,X=map(int, input().split())

i=0
lst = []
while i < N:
    m = map(int, input().split())
    lst.append(list(m))
    i+=1
arr = np.array(lst)

#Xに至らなかったとき
if np.min(np.sum(arr[:,1:], axis=0)) < X:
    print(-1)
    sys.exit()
data = arr[:,1:]
res = []
for i in range(1,N+1):
    for conbi in itertools.combinations(lst, i):
        arrx = np.array(conbi)
        if np.min(np.sum(arrx[:,1:], axis=0)) >= X:
            res.append(np.sum(arrx[:,0]))
    if len(res) > 0:
        print(min(res))
        break

Submission status: Wrong Answer

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

NUM = (10**5) * 12 + 1
ans = NUM
for i in range(1, M+1):
    C = itertools.combinations(B, i)
    for c in C:
        amount = 0
        U = [0 for i in range(M)]
        for k in range(i):
            amount += c[k][0]
            for j in range(M):
                U[j] += c[k][j+1]
        if min(U) >= X:
            ans = min(ans, amount)
if ans == NUM:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
N, M, X = [int(x) for x in input().split()]


C = []
RIKAI = []
ans = 0

#buy = 0b000000001000
#print(buy)

BOOK= []
for i in range(N):
    BOOK += [[int(x) for x in input().split()]]

ans = -1
MIN_PAY = 10**5 * 12

for FLAG in range(2 ** N + 1):
    PAY = 0
    RIKAI = [0] * M
    for i in range(N):
        if FLAG >> i & 1:
            for j in range(M):
                RIKAI[j] = RIKAI[j] + BOOK[i][j+1]
            PAY += BOOK[i][0] 
    if min(RIKAI) >= X:
        MIN_PAY = min(PAY,MIN_PAY)
        

if MIN_PAY == 10 ** 5 * 12:
    ans = -1
else:
    ans = MIN_PAY

print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

cans = np.copy(ans)

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

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

print(min(ans[0], cans[0]))

Submission status: Wrong Answer

Solution code:
import itertools as it

n,m,x=map(int, input().split())
l=[]
check=[0]*(m)
ans=0
for i in range(n):
    a=list(map(int, input().split()))
    ans+=a[0]
    for j in range(m):
        check[j]+=a[j+1]
    l.append(a)

if min(check)<x:
    print('-1')
    exit()


for i in range(1,m+1):
    for p in it.combinations(range(n), i):
        #print(p)
        mon=0
        che=[0]*m
        for j in range(len(p)):
            mon+=l[p[j]][0]
            for k in range(m):
                che[k]+=l[p[j]][k+1]
        #print(che)
        if min(che)>=x:
            ans=min(ans,mon)

print(ans)

Submission status: Wrong Answer

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

import numpy as np

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

vals = np.array(vals)

import itertools

prod = []
for i in range(1, N+1):
    v = list(itertools.combinations(range(N), i))
    prod.extend(v)
    
money = 1e8

for p in prod:
    ans = np.zeros(M+1)
    
    for p_ in p:
        ans += vals[p_]
    
    flag = True
    for j in range(M):
        if ans[j] < X:
            flag = False
    if flag:
        if money > ans[0]:
            money = ans[0]
 
if money >= 1e8:
    print(-1)
else:
    print(int(money))

Submission status: Wrong Answer

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

min_cost = float('inf')
permutations = []
for i in range(1, M + 1):
    permutations.extend(list(map(np.array, combinations(books, i))))


for permutation in permutations:
    sums = np.sum(permutation, axis=0)
    ok = True
    for skill in sums[1:]:
        if skill >= X:
            ok = True
        else:
            ok = False
            break
    if ok:
        min_cost = min(min_cost, sums[0])
if min_cost == float('inf'):
    print(-1)
else:
    print(min_cost)

Submission status: Wrong Answer

Solution code:
import itertools

n,m,x=[int(i) for i in input().split(" ")]
l=[]
for i in range(n):
    l.append([int(i) for i in input().split(" ")])
ans=[]

if x==0:
    ans.append(0)

for i in range(1,n+1):
    for pair in itertools.combinations(l,i):
        sumL=[0]*m
        for p in pair:
            for j in range(m):
                sumL[j]+=p[j+1]
        flag=True
        for j in range(m):
            if sumL[j]<x:
                flag=False
                break
        if flag:
            ans.append(sum([i[0] for i in pair]))

            break

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools
n,m,x = map(int,input().split())
c = [0] * n
a = [0] * n
for i in range(n):
    p = list(map(int,input().split()))
    c[i] = p[0]
    a[i] = list(p[1:])
p_min = float('inf')

for i in range(n):
    un = [0] * m
    for it in itertools.combinations(a,i+2):
        ans = [0] * m
        for li in it:
            ans += np.array(li)
        if all([item >= x for item in ans]):
            p_ans = 0
            for ind in it:
                p_ans += c[a.index(ind)]
            p_min = min(p_min,p_ans)
if p_min == float('inf'):
    print(-1)
else:
    print(p_min)

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
c = [[int(i) for i in input().split()] for _ in range(n)]
import itertools
max_=-1
for i in range(n):
    c_list = list(itertools.combinations(c, i+1))

    for j in c_list:
        d=[0]*m
        for k in j:
            d = [x+y for (x,y) in zip(d,k)]
        f=1
        for l in range(1,m):
            if d[l] < x:
                f=0
                break
        if f==1:
            if max_ ==-1:
                max_ = d[0]
            elif d[0] < max_:
                max_ = d[0]

print(max_)