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:
# -*- coding: utf-8 -*-

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

money = -1
total = 0
X_list = [0]*M

for i in range(N):
    total += int(C[i][0])
    for j in range(M):
        X_list[j] += int(C[i][j+1])

count = 0
for i in X_list:
    if (i >= X):
        count += 1

if (count == M):
    money = total

print("{}".format(money))

for i in range(N):
    count = 0
    for j in range(M):
        if (X_list[j] - int(C[i][j+1]) >= X):
            count += 1
    if (count == M):
        money -= int(C[i][0])
        for j in range(M):
            X_list[j] -= int(C[i][j+1])

print("{}".format(money))

Submission status: Wrong Answer

Solution code:
import itertools
import numpy 

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

price = []
tmp = []

for i in range(N):
  _ = list(map(int, input().split()))
  price.append(_[0])
  tmp.extend(_[1:])
price = numpy.array(price)
learn = numpy.array(tmp).reshape((N, M))

if min(numpy.sum(learn, axis=0)) < X:
  print(-1)
else:
  success_combs = []
  for k in range(2, N):
    for comb in itertools.combinations(range(N), k):
      if min(numpy.sum(learn[comb, :], axis=0)) >= X:
        success_combs.append(comb)

  min_p = None
  for comb in success_combs:
    p = sum(numpy.take(price,comb))
    if min_p is None:
      min_p = p
    elif min_p > p:
      min_p = p
  print(min_p)

Submission status: Wrong Answer

Solution code:
import numpy as np


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

x_list = np.array([ X for i in range(M)])
# print(wv)
# print(x_list)

#安い順に
wv = wv[np.argsort(wv[:,0])]
# print(wv)

def rec(n, uplimit_x):
    ans = 0

    #最後の本までいってだめだった場合
    if n == N:
        return 10**10

    # print(uplimit_x[0:3] - wv[n][1:4])
    # n番目の品物を買って最後の場合(熟練度Xをすべて超えた場合)
    if (np.all(uplimit_x[0:3] - wv[n][1:4]) <= 0):
        return wv[n][0]

    # n番目の品物が使える時
    # -> n番目の品物は買った方がいいのか、買わない方がいいのか...?
    else:
        ans = min(
        rec(n + 1, uplimit_x), #買わない
        rec(n + 1, uplimit_x[0:3] - wv[n][1:4]) + wv[n][0] #買う
        )
    return ans

def solve():
    ans = rec(0,x_list)
    if ans >= 10**5:
        print(-1)
    else:
        print(ans)

def main():
    solve()

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np

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

num = [i for i in range(n)]

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


for k in range(1, n+1):
  correct = []

  for v in itertools.combinations(num, k):
    test = [] #組み合わせを作る
    for j in v:
      test.append(book_list[j])
      sum_test = np.sum(test, axis = 0) #組みあわせの合計
      cnt = 0
      for i in range(1, m+1):
        if sum_test[i] >= x:
          cnt += 1
      if cnt == m:
        correct.append(sum_test[0]) #正解を入れる
  if sum(correct) > 0:
    print(min(correct))
    exit()
print('-1')

Submission status: Wrong Answer

Solution code:
import itertools
import sys

n, m, x = map(int, input().split())
num = list(list(map(int, input().split())) for i in range(n))

s = [i for i in range(n)]
t = []
list_num = []

for i in range(m):
  t.append(list(map(list, itertools.combinations(s, i + 1))))

for i in t:
  for j in i:
    k = [0] * m
    for z in j:
      k = tuple(x + y for (x,y) in zip(k, num[z]))
    list_num.append(k)


list_num = list(sorted(list_num, key =lambda w : w[0]))


for i in list_num:
  flag = 1
  for j in range(1, len(i)):
    if(i[j] < x):
      flag = 0
      break
  if(flag == 1):
    print(i[0])
    sys.exit()
 
print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
from itertools import combinations
N, M, X = map(int, input().split())
T = []
cost = 0
is_update = False
for _ in range(N):
    t = list(map(int, input().split()))
    T.append(t)
    cost += t[0]

combs = []
for i in range(1, N+1):
    combs.append(np.array(list(combinations(T, i))))

for comb in combs:
    for c in comb:
        _cost = c[:, 0].sum()
        if (c[:, 1:].sum(axis=0) >= X).all() and _cost < cost:
            cost = _cost
            is_update = True
print(cost if is_update else -1)

Submission status: Wrong Answer

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


for Books in range(N):
    B_list.append(list(map(int, input().split())))
# print(B_list)

bug = []
for k in range(M + 1):
    bug.append(0)

ways = []

for way in range(2**N):
    for book in range(N):
        if ((way >> book) & 1) == 1:
            for i in range(M + 1):
                bug[i] += B_list[book][i]

    # print(bug)
    clear = [l for l in bug if l >= X]
    # print(clear)
    if len(bug) == len(clear):
        ways.append(bug[0])

    bug = []
    for k in range(M + 1):
        bug.append(0)

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

Submission status: Wrong Answer

Solution code:
from itertools import combinations
import numpy as np

N,M,X=map(int, input().split())
list_=[list(map(int, input().split())) for _ in range(N)]
gokei=X
cost=100001
list_C=[]

for i in range(N):
	list_C=np.array(list(combinations(list_,N-i)))
	count=0
	for h in range(len(list_C)):
		if all(np.sum(list_C[h], axis=0)[1:]>=X) and np.sum(list_C[h], axis=0)[0]<cost:
			cost=np.sum(list_C[h], axis=0)[0]
			count+=1
	if count==0:
		break

print(cost if cost<100001 else -1)

Submission status: Wrong Answer

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

grasp = []  # 理解度
for i in range(m):
  grasp.append(0)

  cost = 0
  check = -1
for i in range(n):
  li = input().split()
  li_int = [int(str) for str in li]
  cost += li_int[0]
  del li_int[0]
  grasp = [x + y for (x, y) in zip(grasp, li_int)]
  if min(grasp) >= x:
    check = cost
    break
    
print(check)

Submission status: Wrong Answer

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

resultMoneyArray = []
for i in range(len(ca_array)):
  tmpMoney = ca_array[i][0]
  m_array = [X for i in range(M)]
  for k in range(M):
    m_array[k] -= ca_array[i][k + 1]
  if sum(x > 0 for x in m_array) == 0:
    resultMoneyArray.append(tmpMoney)
    break
  for j in range(i+1, len(ca_array)):
    tmpMoney += ca_array[j][0]
    for k in range(M):
      m_array[k] -= ca_array[j][k + 1]
    if sum(x > 0 for x in m_array) == 0:
      resultMoneyArray.append(tmpMoney)
      break

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

Submission status: Wrong Answer

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


# 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 = map(int, input().split())
    CA = []
    for _ in range(N):
        CA.append([int(i) for i in input().split()])
        CA.sort()
    sums = [X] * M
    cost = 0
    for ca in CA:
        cost += ca[0]
        for i in range(M):
            sums[i] -= ca[i + 1]
    for i in range(len(sums)):
        if sums[i] > 0:
            print(-1)
            exit()

    for ca in reversed(CA):
        tmp = []
        for i in range(M):
            tmp.append(ca[i + 1] + sums[i])
            if tmp[i] > 0:
                break
            if i == M - 1:        # 最後まで来たra
                cost -= ca[0]
                sums = [i for i in tmp]
    print(cost)    

        





    

    pass

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import itertools

def list_add(in1, in2):
   return list(map(sum, zip(in1, in2)))

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

n = [i for i in range(N)]
c_sum = 0

for i in range(N):
    min_sum = 10e5
    flag = 0
    for v in itertools.combinations(n,i+1):
        c_sum = 0
        At = [0] * M
        for j in range(len(v)):
            At = list_add(At, A[v[j]])
            c_sum += C[v[j]]
        overX = [k for k in At if k >= X]
        if len(overX) == M:
            min_sum = min([min_sum, c_sum])
            flag = 1
    if flag == 1:
        print(min_sum)
        exit()
print(-1)

Submission status: Wrong Answer

Solution code:
import itertools
from collections import deque

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

_sum = 0
list_A = list()
for _ in range(N):
    A = list(map(int, input().split()))
    list_A.append(A)
    _sum += A[0]

list_all = deque()
for n in range(1, N+1):
    for conb in itertools.combinations(list_A, n):
        list_all.append(list(conb))

ans = _sum + 1
for _ in range(len(list_all)):
    tmp = list_all.popleft()
    see = [0] * M
    var = 0
    for i in range(len(tmp)):
        see = list(map(sum, zip(see, tmp[i][1::M+1])))
        var += tmp[i][0]
    if all(elem >= X for elem in see): ans = min(ans, var)

if ans == _sum + 1: ans = -1

print(ans)

Submission status: Wrong Answer

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

ans = int(1e10)
for i in range(N):
  c,*a = map(int,input().split())

  A.append([c,np.array(a)])

for k in range(1,M+1):
  for i in list(itertools.combinations(A, k)):
    tmp_s = np.array([0 for k in range(M)])
    tmp_c = 0
    for j in i:
      tmp_s += j[1]
      tmp_c += j[0]
    if tmp_c < ans and (tmp_s >=X).all():
      ans = tmp_c
print(ans if ans!=1e10 else -1)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
from itertools import combinations
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

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

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

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

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

N, M, X = MII_split()

books = []
# prices = []
for i in range(N):
    book = LII_split()
    # prices.append(book[0])
    books.append(book)

# books = sorted(books.items(), key=lambda x: sum(x[1]), reverse=True)
# chosen_books = []
# is_chosen = [False for _ in range(N)]
price = 0
min_price = -1
for i in range(N):  # i = 選ぶ本の個数-1

    for tmp_books in combinations(books, i + 1):
        algo_skills = np.array([0 for _ in range(M)])
        price = 0
        for skills in tmp_books:
            algo_skills += np.array(skills[1:])
            price += skills[0]
        if np.all(algo_skills >= X):
            if min_price == -1 or price < min_price:
                min_price = price

print(price)

Submission status: Wrong Answer

Solution code:
import numpy as np
n, m, x = map(int, input().split())
under_stand = np.array([0]*m)
cnt = 0
algo = [list(map(int , input().split())) for _  in range(n)]
cush = [i[0] for i in algo]
cush_algo = {}
for i, j in zip(cush, algo):
  cush_algo[i] = j[1:]
for i in cush:
  under_stand = under_stand + np.array(cush_algo[i])
  cnt += i
if not False in [i >= x for i in under_stand.tolist()]:
  for i in cush:
    under_stand = under_stand - np.array(cush_algo[i])
    if not False in [i >= x for i in under_stand.tolist()]:
      cnt -= i
    else:
      break
else:
  cnt = -1
print(cnt)

Submission status: Wrong Answer

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

AC_List = sorted(C_List, key=lambda x: x[0])

ans = [0]*(M+1)
j = 0

while all([i >= X for i in ans])==False and j <= N-1:
  ans = [a + b for a, b in zip(ans, AC_List[j])]
  j += 1

if all([i >= X for i in ans])==False:
  ans[0] = -1

print(ans[0])

Submission status: Wrong Answer

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

arr = [list(map(int, input().split())) for i in range(N)]
arr = np.array(arr)
sum_arr = np.sum(arr, axis=0)
if(all(sum_arr[1:]>=X)):
  pass
else:
  print(-1)

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))
 
for i in subsets:
  tmp = [0]*(M+1)
  if len(i) == 1:
    sum.append(i[0])
  elif len(i) == 0:
    sum.append([0]*(M+1))
  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 range(len(i)):
    if j==0:
      pass
    elif X > i[j]:
      break
    min_price = min(min_price, i[0])
 
if min_price == 1000000:
  print(-1)
else:
  print(min_price)

Submission status: Wrong Answer

Solution code:
import itertools
import sys

n, m, x = map(int, input().split())
num = list(list(map(int, input().split())) for i in range(n))

s = [i for i in range(n)]
t = []
list_num = []

for i in range(m):
  t.append(list(map(list, itertools.combinations(s, i + 1))))

print(t)

for i in t:
  for j in i:
    k = [0] * m
    for z in j:
      k = tuple(x + y for (x,y) in zip(k, num[z]))
    list_num.append(k)

print(list_num)

list_num = list(sorted(list_num, key =lambda w : w[0]))


for i in list_num:
  flag = 1
  for j in range(1, len(i)):
    if(i[j] < x):
      flag = 0
      break
  if(flag == 1):
    sys.exit()
 
print(-1)

Submission status: Wrong Answer

Solution code:
import itertools

def list_add(in1, in2):
   return list(map(sum, zip(in1, in2)))

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

n = [i for i in range(N)]
c_sum = 0

for i in range(N):
    min_sum = 10e5
    flag = 0
    for v in itertools.combinations(n,i+1):
        c_sum = 0
        At = [0] * M
        for j in range(len(v)):
            At = list_add(At, A[v[j]])
            c_sum += C[v[j]]
        overX = [k for k in At if k >= X]
        if len(overX) == M:
            print(v)
            min_sum = min([min_sum, c_sum])
            flag = 1
    if flag == 1:
        print(min_sum)
        exit()
print(-1)

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)
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 = python_list_add(s, a[0])
                        if i2 == 1 and n >= 2:
                          s = python_list_add(s, a[1])
                        if i3 == 1 and n >= 3:
                          s = python_list_add(s, a[2])
                        if i4 == 1 and n >= 4:
                          s = python_list_add(s, a[3])
                        if i5 == 1 and n >= 5:
                          s = python_list_add(s, a[4])
                        if i6 == 1 and n >= 6:
                          s = python_list_add(s, a[5])
                        if i7 == 1 and n >= 7:
                          s = python_list_add(s, a[6])
                        if i8 == 1 and n >= 8:
                          s = python_list_add(s, a[7])
                        if i9 == 1 and n >= 9:
                          s = python_list_add(s, a[8])
                        if i10 == 1 and n >= 10:
                          s = python_list_add(s, a[9])
                        if i11 == 1 and n >= 11:
                          s = python_list_add(s, a[10])
                        if i12 == 1 and n >= 12:
                          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+1)
if len(ans) > 0:
  print(min(ans))
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
from itertools import*
N,M,X=map(int,input().split())
C=[list(map(int,input().split())) for i in range(N)]
ans=100**10000
for i in range(N+1):
    a=list(combinations(C,i))
    for s in a:
        A=[0 for d in range(M)]
        flag=True
        for k in range(M):
            for u in range(len(s)):
                A[k]+=s[u][k]
        B=A[1:]
        for z in B:
            if z>=X:
                continue
            else:
                flag=False
                break
        if flag==True:
            ans=min(ans,A[0])
print(-1 if ans==100**10000 else ans)

Submission status: Wrong Answer

Solution code:
# coding:utf-8
import itertools
n, m, x = map(int, input().split())

book = [list(map(int, input().split())) for _ in range(n)]
all_book = [0] * m
tmp = [0] * m
index = [_ for _ in range(1, m)]

for i in range(0, n):
    for j in range(0, m):
        all_book[j] += book[i][j]

for i in range(1, m):
    if all_book[i] < x:
        print(-1)
        exit()

price = all_book[0]
# print(price)
book_s = sorted(book)
# print(book_s)

for i in range(0, n):
    for j in range(0, m):
        tmp[j] += book_s[i][j]
        if all(item >= x for item in tmp):
            price = min(price, tmp[0])
            break

for i in range(0, n):
    if all(item >= x for item in all_book):
        price = (min(price, all_book[0]))
    else:
        print(price)
        exit()
    for j in range(0, m):
        all_book[j] -= book[i][j]

Submission status: Wrong Answer

Solution code:
import numpy as np

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

C = np.array([list(map(int, input().split())) for _ in range(N)])
# print(C)
sum_C = np.sum(C,axis=0)
# print(sum_C)

for num in sum_C:
    if num < X:
        print(-1)
        exit()

cost = float("inf")

for ii in [0, 1]:
    for i in range(M+1):
        cc = sorted(C, key=lambda x:x[0], reverse=False)
        ccc = np.array(sorted(cc, key=lambda x:x[i], reverse=ii))
        # print("ccc", ccc)
        sum_Ccopy = np.zeros(M+1)
        for j in range(N):
            sum_Ccopy += ccc[j]

            # print(np.all(sum_Ccopy[1:] >= X))
            # print(sum_Ccopy[0])
            if np.all(sum_Ccopy[1:] >= X):
                cost = min(cost, sum_Ccopy[0])
                # print(sum_Ccopy[0])
                print("sum_Ccopy", sum_Ccopy)
            # print(cost)
    
print(int(cost))

Submission status: Wrong Answer

Solution code:
N,M,X = map(int,input().split())
list1 = [list(map(int,input().split())) for _ in range(N)]
import itertools
res = []
for con in range(N):
  for c in itertools.combinations(list1, con):
    a = [0]*(M+1)
    add = True
    for r in c:
      for i in range(len(r)):
        a[i] += r[i]
    for i in range(1,len(a)):
      if a[i] < X:
        add = False
        break
    if add:
      res.append(a)
min_ = 100000000
idx = None
for i in range(len(res)):
  if res[i][0] < min_:
    min_ = res[i][0]
    idx = i
if idx is None:
  print(-1)
else:
  print(res[idx][0])

Submission status: Wrong Answer

Solution code:
import numpy as np

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

C = np.array([list(map(int, input().split())) for _ in range(N)])
# print(C)
sum_C = np.sum(C,axis=0)
# print(sum_C)

for num in sum_C:
    if num < X:
        print(-1)
        exit()

cost = float("inf")

for ii in [0, 1]:
    for i in range(M+1):
        cc = sorted(C, key=lambda x:x[0], reverse=True)
        ccc = np.array(sorted(cc, key=lambda x:x[i], reverse=ii))
        # print("ccc", ccc)
        sum_Ccopy = np.zeros(M+1)
        for j in range(N):
            sum_Ccopy += ccc[j]

            # print(np.all(sum_Ccopy[1:] >= X))
            # print(sum_Ccopy[0])
            if np.all(sum_Ccopy[1:] >= X):
                cost = min(cost, sum_Ccopy[0])
                # print(sum_Ccopy[0])
                print("sum_Ccopy", sum_Ccopy)
            # print(cost)
    
print(int(cost))

Submission status: Wrong Answer

Solution code:
#C
import numpy as np
flg = True
n,m,x = map(int,input().split())
algo = []
tmp = []
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
    lst_ans = [0 for _ in range(len(lst1))]
    for i in range(len(lst1)):

        l1 = lst1[i]
        l2 = lst2[i]
        l1 -= l2
        lst_ans[i] = l1
    return lst_ans

def check_lst(lst1,target):
    for i in range(len(lst1)):
        if lst1[i] < target:
            return False
        
    return True

if flg:
    for k in range(n):
        gokei_t = gokei
        money_t = money
        for i in range(k,n):
            if check_lst(hikizan(gokei_t,algo[i][1:]),x):

                gokei_t = hikizan(gokei_t,algo[i][1:])
                money_t -= algo[i][0]
            
            
        tmp.append(money_t)
            
            
 

    print(min(tmp))

Submission status: Wrong Answer

Solution code:
import itertools

def main():

    n,m,x = map(int,input().split())
    C = []
    A = []
    for i in range(n):
        array = list(map(int,input().split()))
        C.append(array[0])
        A.append(array[1:])
    cost = 10**6
    for i in range(1,n+1):
        combs = itertools.combinations(range(n), i)
        for comb in combs:
            skill = [0]*m
            cost_tmp = 0
            for e in comb:
                # print(comb)
                cost_tmp += C[e]
                for j in range(m):
                    skill[j] += A[e][j]
            for j in range(m):
                if skill[j] < x:
                    break
                if j == m-1:
                    cost = min(cost, cost_tmp)
    if cost == 10**6:
        print(-1)
        return
    print(cost)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from itertools import combinations

n,m_total,x = [int(i) for i in input().split()]
data = [input() for _ in range(n)]
data = [[int(i) for i in d.split()] for d in data]

min_total = -1
for m in range(1, m_total+1):
    for comb in combinations(data, m):
        c_totals = [sum([c[i] for c in comb]) >= x for i in range(1, m+1)]
        if all(c_totals):
            if min_total == -1:
                min_total = sum([c[0] for c in comb])
            if sum([c[0] for c in comb]) < min_total:
                min_total = sum([c[0] for c in comb])
print(min_total)

Submission status: Wrong Answer

Solution code:
from itertools import*
N,M,X=map(int,input().split())
C=[list(map(int,input().split())) for i in range(N)]
ans=100**10000
for i in range(N+1):
    a=list(combinations(C,i))
    for s in a:
        A=[0 for d in range(M)]
        flag=True
        for k in range(M):
            for u in range(len(s)):
                A[k]+=s[u][k]
        B=A[1:]
        for z in B:
            if z>=X:
                continue
            else:
                flag=False
                break
        if flag==True:
            ans=min(ans,A[0])
print(-1 if ans==100**10 else ans)

Submission status: Wrong Answer

Solution code:
def judge_understand(us_algo, M, X):
    for i in range(M):
        if us_algo[i] < X:
            return False
        else:
            return True


def main():
    N, M, X = map(int, input().split())
    CA = [input().split() for _ in range(N)]
    ans = 10 ** 5 + 1
    Cmoney = 0

    for i in range(N):
        understand_algo = [0] * M

        for j in range(i, N):

            for k in range(M):
                understand_algo[k] = understand_algo[k] + int(CA[j][k + 1])

            Cmoney = Cmoney + int(CA[j][0])
            if judge_understand(understand_algo, M, X):
                ans = min(ans, Cmoney)

    print(ans)


main()

Submission status: Wrong Answer

Solution code:
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
import sys
sys.setrecursionlimit(10**6)
import math
import itertools
from collections import defaultdict
from collections import Counter
import numpy as np

import heapq

n,k,x=list(map(int,input().split()))

c=np.array([list(map(int,input().split())) for _ in range(n)])
kumi=[i for i in range(n)]
ans=float("inf")
for k_n in range(n+1):
    t=itertools.combinations(kumi, k_n)
    if k_n<2:
        continue
    for each in t:
        cal=c[each,:].sum(axis=0)
        if min(cal[1:])>=x:
            ans=min(cal[0],ans)
if ans==float("inf"):
    ans=-1
print(ans)

Submission status: Wrong Answer

Solution code:
def solve():
    N, M, X = map(int, input().split()) 
    import numpy as np
    arr = np.ones((N,M+1), int)
    for i in range(N):
        arr[i] = list(map(int, input().split()))
    
    arr = arr[np.argsort(arr[:, 0])[::-1]]
    C = arr[:, 0].astype(int)
    arr = arr[:, 1:].astype(int)
    # print(C)
    # print(arr)

    if any(np.sum(arr, axis=0) < X):
        return -1

    i = 0
    for _ in range(N):
        if any(np.sum(np.delete(arr, i, axis=0), axis=0) < X):
            i += 1
        else:
            arr = np.delete(arr, i, axis=0)
            C = np.delete(C, i)

    return C.sum()


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

Submission status: Wrong Answer

Solution code:
from itertools import combinations
n , m ,x = map(int , input().split())
arr = [list(map(int , input().split())) for i in range(n)]
ans = 10**10
for i in range(1,n):
	for k in combinations(arr , i):
		#print(k,i,n)
		a = [0]*m
		#print(k)
		f = 1
		cost = 0
		for ele in k:
			#print(ele)
			cost += ele[0]
			for e in range(1,m+1):
				a[e-1] += ele[e]
		for _i in a:
			if _i < x:
				f = 0
				break
		if f : ans = min(ans , cost)
print(ans if ans < 10**10 else -1)

Submission status: Wrong Answer

Solution code:
import sys
import os
import math
import bisect
import collections
import itertools
import heapq

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M, X = il()
    CA = [il() for _ in range(N)]
    # CA.sort(key=lambda x: x[0])
    ret = []
    for i in itertools.permutations(CA):
        k = 0
        x = [0] * N
        for n in range(N):
            c, *a = i[n]
            k += c
            x = [q + p for q, p in zip(x, a)]
            for j in x:
                if j < X:
                    break
                else:
                    ret.append(k)

    print(min(ret) if len(ret) > 0 else -1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


temp_list = [ [int(x) for x in input().split()] for _ in range(n)]
input_2d = np.array(temp_list)
input_2d = np.sort(input_2d, axis=0)
sum_list = np.sum(input_2d, axis=0)

if sum_list.min() < x:
  print(-1)
else:
  print(input_2d)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
from itertools import combinations
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

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

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

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

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

N, M, X = MII_split()

books = []
# prices = []
for i in range(N):
    book = LII_split()
    # prices.append(book[0])
    books.append(book)




# books = sorted(books.items(), key=lambda x: sum(x[1]), reverse=True)
# chosen_books = []
# is_chosen = [False for _ in range(N)]
for i in range(N):  # i = 選ぶ本の個数-1

    for tmp_books in combinations(books, i+1):
        algo_skills = np.array([0 for _ in range(M)])
        price = 0
        for skills in tmp_books:
            algo_skills += np.array(skills[1:])
            price += skills[0]
        if np.all(algo_skills >= X):
            print(price)
            exit()


print('-1')