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:
a=input().split()
N=int(a[0])
M=int(a[1])
X=int(a[2])
list1=[]
for i in range(N) :
  k=input().split()
  k=[int(j) for j in k]
  list1.append(k)
flag1=True
def count(item,i) :
  count1=0
  for a in item :
    count1+=a[i]
  return count1

def algo(item,i) :

  for j in range(1,i+1) :
    if count(item,j)<X :
      return False
  return True


import itertools
for i in range(1,N+1) :
  c=list(itertools.combinations(list1,i))

  value_list=[]
  for item in c :
    item1=list(item)


    if algo(item,M) :
      value_list.append(count(item,0))
  if value_list!=[] :
    print(min(value_list))
    flag1=False

    break
if flag1 :
  print('-1')

Submission status: Wrong Answer

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

A = [[0 for i in range(M)]for i in range(N)]
C=[0]*(2**N)
for i in range(N):
    A[i] = list(map(int,input().split()))
for i in range(2 ** N):
    Ad = []
    for j in range(N):
        if (i >> j) & 1  == 1:
            Ad.append(A[j])

    
    xs = [0]*(M+1)
    for k in range(len(Ad)):
        C[i]+=Ad[k][0]
        for l in range(1,M+1):
            xs[l] += Ad[k][l]      
        
    flag = True

    for l in range(1,M+1):
        if xs[l] >= X:
            continue
        else:
            flag = False
            

    if flag and m > C[i]:

        m = C[i]

if m < 1000000:
    print(m)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import itertools as t
n,m,z=map(int,input().split())
l=[]
answer=set([])
for i in range(n):
    l.append(list(map(int, input().split())))
for k in range(n+1):
    a=list(t.combinations(range(n),k))
    for x in a:
        w=0
        A=[0 for _ in range(m)]
        s=0
        for y in x:
            w+=l[y][0]
            for k in range(m):
                A[k]+=l[y][k]
        for u in A:
            if u<z:
                s=1
        if s==0:
            answer.add(w)
if answer:
    print(min(answer))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
import numpy as np

n,m,x = map(int, input().split())
q = [np.array(list(map(int, input().split()))) for _ in range(n)]
L=[]
for i in range(1,n):
    for j in list(combinations(q,i)):
        S = np.sum(j, axis=0)
        if all([k >= x for k in S[1:]]):
            L.append(S[0])

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

Submission status: Wrong Answer

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

for i in range(1, m+1):
    base_ = 0
    for j in range(n):
        base_ += data_list[j][i]
        
    if base_ < base:
        base = base_

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

Submission status: Wrong Answer

Solution code:
import sys
import itertools
# import math
# from pprint import pprint
import numpy as np


N,M,X = map(int, sys.stdin.readline().strip().split())
C = []
for _ in range(0, N):
    C.append(list(map(int, sys.stdin.readline().strip().split())))

# N = 3
# M = 3
# X = 10
#
# C = [
#     [60,2,2,4],
#     [70,8,7,9],
#     [50,2,3,9],
# ]

C.sort(key=lambda x:x[0])

for i in range(1, N+1):
    for j in itertools.combinations(C, i):
        l = [k[1:] for k in j]
        # pprint(l)
        if len(l) > 1:
            ll = np.sum(l, axis=0)
            # print(ll)
            flag = all((m >= X) for m in ll)
        else:
            flag = all((m >= X) for m in l[0])
        if flag:
            print(np.sum(j, axis=0)[0])
            sys.exit()
print(-1)

Submission status: Wrong Answer

Solution code:
import sys
N,M,X=map(int,input().split())
L=[list(map(int,input().split())) for i in range(N)]
#print(L)
price=[]
list_X=[X for i in range(M)]
print(list_X)
for i in range(2**N):
  A=[0 for i in range(M+1)]
  for j in range(N):
    if (i>>j) & 1:
      A = [x+y for (x,y) in zip(A,L[j])] 
  #print(A)
  large = 0
  for i in range(M):
    if A[i+1] >= list_X[i]:
      large += 1
  if large == M:
    price.append(A[0])
  #if A[1:] >= list_X:
    #price.append(A[0])
#print(price)
if price ==[]:
  print(-1)
else:
  print(min(price))

Submission status: Wrong Answer

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

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

C_list = []
A_list = []

for i in range(N):
    inp = list(map(int, input().rstrip().split()))
    C_list.append(inp[0])
    A_list.append(inp[1:])
#-----

bit = 1 << N
max_price = sum(C_list)
min_price = max_price

for b in range(bit):
    price = 0
    study = [0]*M
    
    for i in range(N):
        if (b & (1 << i)):
            price += C_list[i]
            
            for j in range(len(A_list[i])):
                study[j] += A_list[i][j]
    
    if min(study) >= X:
        min_price = min(min_price, price)


print(min_price if min_price != max_price else -1)

Submission status: Wrong Answer

Solution code:
n, m, x = list(map(int, input().split()))
a = []
c = []
for _ in range(n):
    list_ = list(map(int, input().split()))
    c.append(list_[0])
    list_.pop(0)
    a.append(list_)
res = -1
bit = []
for i in range(2 ** n):
    tmp = [False] * n
    for j in range(n):
        if i >> j & 1:
            tmp[j] = True
    bit.append(tmp)
bit.pop(0)
cost = 10 ** 10
f = False
for i in range(2 ** n - 1):
    tmp_cost = 0
    tmp_f = True
    list_ = [0] * m
    for j in range(n):
        if bit[i][j]:
            tmp_cost += c[j]
            for k in range(m):
                list_[k] += a[j][k]
    for k in range(m):
        if list_[k] >= x:
            pass
        else:
            tmp_f = False
    if tmp_f:
        cost = min(tmp_cost, cost)
        f = True
        break
if f:
    res = cost
print(res)

Submission status: Wrong Answer

Solution code:
from functools import lru_cache
import sys

#@lru_cache(maxsize=1000)
def dfs(A,B):
    for i in range(1,m):
        if A[i]<x:
            break
        B.append(A[0])
        return
    for i in range(n):
        if i in check:
            continue
        else:
            check.append(i)
        for j in range(m+1):
            A[j]+=text[i][j]
        dfs(A,B)
        for j in range(m+1):
            A[j]-=text[i][j]
        check.remove(i)
if __name__=="__main__":
    sys.setrecursionlimit(10000)
    n,m,x=map(int,input().split())
    text=[]
    for i in range(n):
        tmp=list(map(int,input().split()))
        text.append(tmp)
    total=[0]*(m+1)
    ans=[]
    check=[]
    dfs(total,ans)
    if len(ans)==0:
        print(-1)
    else:
        print(min(ans))

Submission status: Wrong Answer

Solution code:
import copy
import itertools
import sys

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

us = [0 for _ in range(m)]

l = []
for i in range(n):
    row = [int(i) for i in input().split()]
    l.append(copy.deepcopy(row))

# 最初の一つをx以上にする組み合わせ
first = []
c = 0
for i in range(1, n+1):
    c = itertools.combinations(range(n), i)
    for v in c:
        total = 0
        for e in v:
            total += l[e][1]
        if total >= x:
            first.append(v)

for i in range(2, m+1):
    cc = copy.deepcopy(first)
    first = []
    for v in cc:
        total = 0
        for e in v:
            total += l[e][i]
        if total >= x:
            first.append(v)

if len(first) == 0:
    print(-1)
    sys.exit()

ans = 100000+1
for i in first:
    t = 0
    for j in i:
        t += l[j][0]
    if ans > t:
        ans = t

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N, M, X = map(int, input().split())
C = np.array([[int(i) for i in input().split()] for j in range(N)])

memo = np.array([0 for i in range(M)])

def check(memo):
    for i in memo:
        if i < X:
            return False
    return True

def rec(i, cost, memo):
    if i == N:
        if check(memo):
            return cost
        return float("inf")
    
    # i番目を選ばない    
    # i番目を選ぶ
    return min(rec(i+1, cost, memo), rec(i+1, cost+C[i, 0], memo+C[i, 1:]))

print(rec(0, 0, memo))

Submission status: Wrong Answer

Solution code:
#C
import numpy as np
flg = True
n,m,x = map(int,input().split())
algo = []
for _ in range(n):
    algo.append(list(map(int,input().split())))
    

algo_n = np.array(algo)
algo_sum = algo_n.sum(axis=0)
gokei = algo_sum.tolist()
money = gokei[0]
gokei = gokei[1:]

#チェックする
for i in range(m):
    if gokei[i] < x:
        flg = False
        print(-1)
        break

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

#print(algo)
#print(gokei)
# 計算用の関数
def hikizan(lst1,lst2):
#lst1 - lst2
    for i in range(len(lst1)):
        l1 = lst1[i]
        l2 = lst2[i]
        l1 -= l2
        lst1[i] = l1
            
    return lst1

if flg:
    for i in range(n):
        flg = True
        for j in range(1,m+1):
            if gokei[j-1] - algo[i][j] < x:
                flg = False
                pass
        if flg:
            gokei = hikizan(gokei,algo[i][1:])
            money -= algo[i][0]
        
print(money)

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
f=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]
for i in range(m):
  if k[i]<x:
    break
  else:
    f+=1
d=[]
l.sort()
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]
    ans-=d[i][0]
if f!=m:
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    [n, m, x] = [int(i) for i in input().split(" ", 3)]
    # u = {i: 0 for i in range(m)}
    # s = 0
    # is_succeeded = False
    books = [[int(j) for j in input().split(" ")]
             for i in range(n)]
    """for b in books:
        s += b.pop(0)
        for j, k in enumerate(b):
            u[j] += k
        if x <= min(list(u.values())):
            is_succeeded = True
            break
    print(s if is_succeeded else "-1")"""
    r = set()
    for i in range(m):
        t = sorted([[j, k[i + 1]]
                    for j, k in enumerate(books)], key=lambda x: x[1])
        t.reverse()
        b = 0
        for l in t:
            b += l[1]
            r.add(l[0])
            if x <= b:
                break
        if not x <= b:
            print("-1")
            return
    print(sum([books[i][0] for i in r]))


main()

Submission status: Wrong Answer

Solution code:
from itertools import combinations
import numpy as np
n,m,x=map(int, input().split())

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

ans = 10**9
for i in range(2,n+1):
    for comb in combinations(S,i):
        tmp = np.array([0]*m)
        
        cost = 0
        for s in comb:
            tmp += np.array(s[1:])
            cost += s[0]
        #print(tmp)
        #print(cost)
        cnt = 0
        for t in tmp:
            if t >= x: cnt+=1
        #print(cnt,m)
        if cnt == m:
            ans = min(ans,cost)
if ans == 10**9:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
def python_list_add(in1, in2):
  for i in range(len(in1)):
    in1[i] = in1[i] + in2[i]
  return in1
  
n, m, x = map(int, input().split())
a = []
for i in range(n):
  a.append(list(map(int, input().split())))
ans = []
s = [0]*(m+1)
s = python_list_add(s, a[0])
for i1 in range(2):
  for i2 in range(2):
    for i3 in range(2):
      for i4 in range(2):
        for i5 in range(2):
          for i6 in range(2):
            for i7 in range(2):
              for i8 in range(2):
                for i9 in range(2):
                  for i10 in range(2):
                    for i11 in range(2):
                      for i12 in range(2):
                        if i1 == 1 and n >= 1:
                          #s = s + a[0]
                          s = python_list_add(s, a[0])
                        if i2 == 1 and n >= 2:
                          #s = s + a[1]
                          s = python_list_add(s, a[1])
                        if i3 == 1 and n >= 3:
                          #s = s + a[2]
                          s = python_list_add(s, a[2])
                        if i4 == 1 and n >= 4:
                          #s = s + a[3]
                          s = python_list_add(s, a[3])
                        if i5 == 1 and n >= 5:
                          #s = s + a[4]
                          s = python_list_add(s, a[4])
                        if i6 == 1 and n >= 6:
                          #s = s + a[5]
                          s = python_list_add(s, a[5])
                        if i7 == 1 and n >= 7:
                          #s = s + a[6]
                          s = python_list_add(s, a[6])
                        if i8 == 1 and n >= 8:
                          #s = s + a[7]
                          s = python_list_add(s, a[7])
                        if i9 == 1 and n >= 9:
                          #s = s + a[8]
                          s = python_list_add(s, a[8])
                        if i10 == 1 and n >= 10:
                          #s = s + a[9]
                          s = python_list_add(s, a[9])
                        if i11 == 1 and n >= 11:
                          #s = s + a[10]
                          s = python_list_add(s, a[10])
                        if i12 == 1 and n >= 12:
                          #s = s + a[11]
                          s = python_list_add(s, a[11])
                        do = True
                        for j in s[1:]:
                          if j < x:
                            do = False
                            break
                          if do:
                            ans.append(s[0])
                        s = [0]*m
if len(ans) > 0:
  print(min(ans))
else:
  print(-1)

Submission status: Wrong Answer

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

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

li = [f'{i:012b}' for i in range(2**N)]
C = []
A = []
for i in range(N):
    B = list(map(int, input().split()))
    C.append(B[0])
    A.append(B[1:])

d = []
for l in li:
    b = l[::-1][:N]
    rikai = [0]*M
    pri = [0]*N
    for i in range(len(b)):
        if b[i] == '1':
            for j in range(M):
                rikai[j] += A[i][j]
            pri[i] += C[i]
    d.append((sum(pri), rikai))

ans = 10**5+1
for s in d:
    f = True
    for r in s[1]:
        if r < X:
            f = False
            break
    if f:
        ans = min(ans, int(s[0]))
if ans == 10**5+1:print(-1)
else: print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque
import itertools

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

li = deque()

sum = -1
ans = 0
for i in range(n):
    li.append(list(map(int, input().split())))

for i in range(1,n+1):
    for v in itertools.permutations(li, i):
        ok = True
        for j in range(1,m+1):
            ans = 0
            for k in v:
                ans += k[j]
                if ans >= x:
                    break
            if ans < x:
                ok = False
                break

        if ok == True:
            s=0
            for j in range(i):
                s+=v[j][0]
            if sum > s or sum == -1:
                sum=s
    if sum > -1:
        break


print(sum)

Submission status: Wrong Answer

Solution code:
from itertools import permutations

INF=float('inf')

def main():
    N,M,X=map(int,input().split())
    flag=0
    ans=INF
    CA=[[int(_) for _ in input().split()] for _ in range(N)]
    for i in range(1,M+1):
        for ca in permutations(CA,i):
            money=0
            tmp=[0]*M
            for c in ca:
                money+=c[0]
                for i in range(len(c)-1):
                    tmp[i]+=c[i+1]
                if min(tmp)>=X:
                    ans=min(ans, money)
    print(ans if ans != INF else -1)
main()

Submission status: Wrong Answer

Solution code:
import sys
N, M, X = map(int, sys.stdin.readline().split())
CA = [list(map(int, sys.stdin.readline().split())) for i in range(N)]
ans = 10 ** 20
for i in range(2 ** N):
    TMP = [0] * len(CA)
    op = [1] * N
    for j in range(N):
        if (i >> j) & 1:
            op[j] = 0
    for k in range(len(op)):
        if op[k]:
            TMP = list(map(lambda x,y: x + y, TMP, CA[k]))
    TMP_2 = [l for l in TMP[1:] if l >= X]
    if len(TMP_2) + 1 == len(TMP):
        ans = min(ans, TMP[0])
if ans == 10 ** 20:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

for i in range(1, m+1):
    base_ = 0
    for j in range(n):
        base_ += data_list[j][i]
        
    if base_ < base:
        base = base_

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

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
f = 0
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)
    f+=1

    
if f==0:
  print(-1)
  exit()
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 ** 6

    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

N,M,X=map(int, input().split())
data=[]
ans=999999999
b=[]
b_pairs=[]
for i in range(N):
    b.append(i)
for i in range(N):
    data.append(list(map(int, input().split())))

for i in range(2,N+1):
    b_pairs+=itertools.combinations(b,i)

for i in range(N):
    flag=1
    skill=[0]*M
    for j in range(M):
        skill[j]+=data[i][j+1]
    for j in range(M):
        if skill[j]<X:
            flag=0
    if flag==1:
        ans=min(ans,data[i][0])

for i in range(len(b_pairs)):
    skill=[0]*M
    sum=0
    flag=1
    for k in range(len(b_pairs[i])):
        sum+=data[b_pairs[i][k]][0]
        for j in range(1,M+1):
            skill[j-1]+=data[b_pairs[i][k]][j]
    for h in range(M):
        if skill[h]<X:
            flag=0
    print(flag)
    if flag==1:
        ans=min(ans,sum)

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

Submission status: Wrong Answer

Solution code:
import itertools

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

kakaku = 100000
combinations = []
for n in range(N):
    combinations += list(itertools.combinations(range(N), n))


for pair in combinations:
    hantei = True
    for m in range(M):
        total = 0
        for i in pair:
            total += CA[i][m+1]
        if X <= total:
            continue
        else:
            hantei = False
            break
    if hantei:
        kingaku = 0
        for i in pair:
            kingaku += CA[i][0]
        kakaku = min(kakaku, kingaku)
    else:
        continue

if kakaku == 100000:
    print(-1)
else:
    print(kakaku)

Submission status: Wrong Answer

Solution code:
import itertools
N, M, X = map(int, input().split())
a = [list(map(int, input().split())) for i in range(N)]
li = []
for i in range(N):
    for j in itertools.combinations(range(N), i):
        sm = [0] * (M+1)
        for k in j:
            for l in range(M+1):
                sm[l] += a[k][l]
        if all(y >= X for y in sm[1:M+1]):
            li.append(sm[0])
if li == []:
    print(-1)
else:
    print(min(li))

Submission status: Wrong Answer

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

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


min_val = 10 ** 6

ans = False

for bit in range(1 << N):
    R = [0] * M
    c = 0

    for i in range(N):
        if bit & (1 << i):
            c += C[i]
            for m in range(M):
                R[m] += A[i][m]

    if all([r >= X for r in R]):
        ans = True
        min_val = min(min_val, c)


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

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
CA = [0]*N
for i in range(N):
    CA[i] = list(map(int, input().split()))
print(CA)

INF = 10**7
ans = INF
for t in range(2**N):
    tmp = 0
    check = [X]*M
    for i in range(N):
        if (t >> i) & 1 == 1:
            tmp += CA[i][0]
            for j in range(M):
                check[j] -= CA[i][j+1]
    for ch in check:
        if ch > 0:
            break
    else:
        if tmp < ans:
            ans = tmp

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

Submission status: Wrong Answer

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

for i in range(1, m+1):
    base_ = 0
    for j in range(n):
        base_ += data_list[j][i]
        
    if base_ < base:
        base = base_

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
from collections import deque
import numpy as np
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,m,x=mp()
l=np.array(sorted([lmp() for i in range(n)],key=lambda x: x[0],reverse=True))
s=np.sum(l, axis=0)
for i in range(1,m+1):
    if s[i]<x:
        print(-1)
        exit()
for i in range(n):
    c=0
    for k in range(1,m+1):
        if s[k]-l[i][k]<x:
            c=1
    if c==0:
        for k in range(0,m):
            s[k]-=l[i][k]
print(s[0])

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np

N,M,X = map(int,input().split())
CA = [list(map(int,input().split())) for i in range(N)]
CA = np.array(CA)
# print(CA)

C = [CA[i][0] for i in range(N)]
# print(C)
min_ans = 10**7

l = range(N)

for i in range(N-1):
    c = list(itertools.combinations(l, i+2))
    for j in range(len(c)):
        # print(c[j])
        alg_sum = 0
        target_book = np.array([CA[a] for a in c[j]])
        # print(target_book)
        rikai = np.sum(target_book,axis=0)
        # print(rikai)
        if min(rikai[1:]) >= X and min_ans > rikai[0]:
            min_ans = rikai[0]

if min_ans != 10**7:
    print(min_ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import itertools as t
n,m,z=map(int,input().split())
l=[]
answer=set([])
for i in range(n):
    l.append(list(map(int, input().split())))
for k in range(n):
    a=list(t.combinations(range(n),k))
    for x in a:
        w=0
        A=[0 for _ in range(m)]
        s=0
        for y in x:
            w+=l[y][0]
            for k in range(m):
                A[k]+=l[y][k]
        for u in A:
            if u<z:
                s=1
        if s==0:
            answer.add(w)
if answer:
    print(min(answer))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

values = []
scores = []
greedy = []
for _ in range(N):
    tmp = list(map(int, input().split()))
    values.append(tmp[0])
    scores.append(tmp[1:])
    greedy.append(np.sum(scores)/tmp[0])

values = np.array(values)
scores = np.array(scores)

selected = []
finished = []
finisheds = np.zeros(M)
ans = 0
while len(finished) != M and np.sum(greedy)!=0:
    arg = np.argmax(greedy)
    selected.append(arg)
    finisheds += scores[arg]
    ans += values[arg]
    scores[selected] = 0
    args = np.where(finisheds>=X)[0]
    finished.extend(list(args))
    finished = list(set(finished))
    for arg in args:
        scores[:, arg] = 0
    greedy = np.sum(scores, axis=1)/values

if len(finished) == M:
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

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

C=[0] * N
A=[0] * N

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

n=0
s=100000000

for i in range(2**N-1):
  score=[0]*M
  s_tmp=0
  for j in range(N):
    
    if ((1 << j) & i) >> j == 1:
      s_tmp+=C[j]
      for k in range(M):
        score[k]+=A[j][k]
  flg=1
  for k in range(M):
    if score[k] < X:
      flg=0
      break
  if flg==1:
    if s_tmp < s:
      s=s_tmp
if s == 100000000:
  print(-1)
else:
  print(s)

Submission status: Wrong Answer

Solution code:
import numpy as np
from itertools import product

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

CA = []

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

CA = np.array(CA)

C = CA[:, 0]
A = CA[:, 1:]

whole = np.array(list(product([0,1],repeat=N)), np.bool)

ans_tmp = []

for p in whole:
    score = A[p].sum(axis=0)
    ans_tmp.append(score[np.where(score>=X)].shape[0]==M)

pattern = whole[ans_tmp]

score = A[whole[1]].sum(axis=0)

ans = 1000000
for p in pattern:
    tmp = C[p].sum()
    if ans > tmp:
        ans = tmp

print(ans) if ans != 1000000 else print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np

n, m, x = list(map(lambda x: int(x), input().split(' ')))


sets = []

for i in range(n):
  sets.append(list(map(lambda x: int(x), input().split(' '))))  
sets = np.array(sets)


mincost = 10000000
maxnum = int(''.join(["1" for i in range(n)]), 2)

if not np.all((np.sum(sets[:, 1:], axis=0) > x)):
  print(-1)
else:
  for i in range(0, maxnum+1):
    status = np.array(list(format(i, '0{}b'.format(n)))) == '1'
    used_data = sets[status]
    cost = np.sum(used_data[:, 0])
	
    if cost > mincost:
      continue
    if np.all((np.sum(used_data[:, 1:], axis=0) >= x)):
      if cost < mincost:
        mincost = cost
        next
    
  print(mincost)

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np
import sys

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

C = []
A = []
ALL = []

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

ALL = np.sort(ALL, axis=0)

ok_index = []
for n in range(N):
  for i in itertools.permutations(ALL, r=n+1):
      if n > 0:
        this_ar = np.sum(np.array(i), axis=0)
      else:
        this_ar = np.array(i)[0]
      if np.all(this_ar[1:]>=X):
        ok_index.append(this_ar[0])
  if len(ok_index) > 0:
    print(np.min(ok_index))
    sys.exit()
if len(ok_index)==0:
  print(-1)
else:
  print(np.min(ok_index))

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
f=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]
for i in range(m):
  if k[i]<x:
    break
  else:
    f+=1
d=sorted(l)
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]
    ans-=d[i][0]
if f!=m:
  print(-1)
else:
  print(ans)