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:
from operator import add
N, M, X = map(int, input().split())


def toItem(line):
    xs = line.split()
    cost = int(xs[0])
    values = list(map(int, xs[1:]))
    return (cost, values)


Items = [toItem(input()) for i in range(N)]
maxCost = 10 ** 10


def rec(i, proficiency, totalCost):
    if i == N:
        if all([x >= X for x in proficiency]):
            return totalCost
        else:
            return maxCost
    else:
        _proficiency = list(map(add, proficiency, Items[i][1]))
        _totalCost = totalCost + Items[i][0]
        if all([x >= X for x in _proficiency]):
            return _totalCost
        else:
            cost1 = rec(i + 1, proficiency, totalCost)
            cost2 = rec(i + 1, _proficiency, _totalCost)
            if cost1 < cost2:
                return cost1
            else:
                return cost2
            # return min(cost1, cost2)


cost = rec(0, [0] * M, 0)
if cost == maxCost:
    print("-1")
else:
    print(cost)

Submission status: Wrong Answer

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


def toItem(line):
    xs = line.split()
    cost = int(xs[0])
    values = list(map(int, xs[1:]))
    return (cost, values)


Items = [toItem(input()) for i in range(N)]
maxCost = 10 ** 10


def rec(i, proficiency, totalCost):
    if i == N:
        if all(map(lambda x: x >= X, proficiency)):
            return totalCost
        else:
            return maxCost
    else:
        _proficiency = [a + b for (a, b) in zip(proficiency, Items[i][1])]
        _totalCost = totalCost + Items[i][0]
        if all(map(lambda x: x >= X, _proficiency)):
            return _totalCost
        else:
            cost1 = rec(i + 1, proficiency, totalCost)
            cost2 = rec(i + 1, _proficiency, _totalCost)
            if cost1 < cost2:
                return cost1
            else:
                return cost2
            # return min(cost1, cost2)


cost = rec(0, [0] * M, 0)
if cost == maxCost:
    print("-1")
else:
    print(cost)

Submission status: Wrong Answer

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


def toItem(line):
    xs = line.split()
    cost = int(xs[0])
    effects = list(map(int, xs[1:]))
    return (cost, effects)


Items = [toItem(input()) for i in range(N)]


maxCost = 10 ** 10


def rec(i, proficiency, totalCost):
    if i == N:
        if all(map(lambda x: x >= X, proficiency)):
            return totalCost
        else:
            return maxCost
    else:
        _proficiency = [a + b for (a, b) in zip(proficiency, Items[i][1])]
        _totalCost = totalCost + Items[i][0]
        if all(map(lambda x: x >= X, _proficiency)):
            return _totalCost
        else:
            cost1 = rec(i + 1, proficiency, totalCost)
            cost2 = rec(i + 1, _proficiency, _totalCost)
            return min(cost1, cost2)


cost = rec(0, [0] * M, 0)
if cost == maxCost:
    print("-1")
else:
    print(cost)

Submission status: Wrong Answer

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


def create(line):
    xs = line.split()
    cost = int(xs[0])
    effects = list(map(int, xs[1:]))
    return (cost, effects)


Items = [create(input()) for i in range(N)]


maxCost = 10 ** 10


def rec(i, proficiency, totalCost):
    if i == N:
        if all(map(lambda x: x >= X, proficiency)):
            return totalCost
        else:
            return maxCost
    else:
        _proficiency = [a + b for (a, b) in zip(proficiency, Items[i][1])]
        _totalCost = totalCost + Items[i][0]
        if all(map(lambda x: x >= X, _proficiency)):
            return _totalCost
        else:
            cost1 = rec(i + 1, proficiency, totalCost)
            cost2 = rec(i + 1, _proficiency, _totalCost)
            return min(cost1, cost2)


cost = rec(-1, [0] * M, 0)
if cost == maxCost:
    print("-1")
else:
    print(cost)

Submission status: Wrong Answer

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


def create(line):
    xs = line.split()
    cost = int(xs[0])
    effects = list(map(int, xs[1:]))
    return (cost, effects)


Items = [create(input()) for i in range(N)]


maxCost = 10 ** 10


def rec(i, proficiency, totalCost):
    if i == N:
        if all(map(lambda x: x >= X, proficiency)):
            print(f"satisfied: {proficiency}, totalCost: {totalCost}")
            return totalCost
        else:
            return maxCost
    else:
        _proficiency = [a + b for (a, b) in zip(proficiency, Items[i][1])]
        _totalCost = totalCost + Items[i][0]
        if all(map(lambda x: x >= X, _proficiency)):
            return _totalCost
        else:
            cost1 = rec(i + 1, proficiency, totalCost)
            cost2 = rec(i + 1, _proficiency, _totalCost)
            return min(cost1, cost2)


cost = rec(-1, [0] * M, 0)
if cost == maxCost:
    print("-1")
else:
    print(cost)

Submission status: Wrong Answer

Solution code:
from itertools import product
N, M, X = map(int, input().split())

val0 = [0]*M
ans = 10**10000
val = []
for _ in range(N):
    val.append(list(map(int, input().split())))

for i in range(2**N):
    ls = ["+"]*N
    for j in range(len(ls)):
        if (i >> j) & 1:
            ls[j] = "-"
    for m, n in enumerate(ls):
        if n == '+':
            val0 = [x + y for (x, y) in zip(val0, val[m])]
    if ans > val0[0]:
        for k, l in enumerate(val0[1:]):
            if l < X:
                break
            elif k == len(val0[1:])-1:
                ans = val0[0]
    val0 = [0]*M
        
if ans == 10**10000:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import product
N, M, X = map(int, input().split())

val0 = [0]*M
ans = 0
val = []
for _ in range(N):
    val.append(list(map(int, input().split())))

for i in range(2**N):
    ls = ["+"]*N
    for j in range(len(ls)):
        if (i >> j) & 1:
            ls[j] = "-"
    for m, n in enumerate(ls):
        if n == '+':
            val0 = [x + y for (x, y) in zip(val0, val[m])]
    if ans > val0[0] or ans == 0:
        for k, l in enumerate(val0[1:]):
            if l < X:
                break
            elif k == len(val0[1:])-1:
                ans = val0[0]
    val0 = [0]*M
        
if ans == 0:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N, M, X = (int(x) for x in input().split())
val = []
for i in range(N):
    exec("c%d = input().split()" % N)
    exec("val.append(c%d)" % N)

exec("tol=[0]*%d" % (M+1))
val = sorted(val)
print(val)


for i in val:
    for j, k in enumerate(i):
        tol[j] += int(k)

    for m, l in enumerate(tol[1:]):
        print(l)
        if l < 10:
            continue
        elif m == M -2:
            print(tol[0])
            exit()
print("-1")

Submission status: Wrong Answer

Solution code:
import numpy as np

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

books = []
total_price = 0
total_scores = np.zeros(m)
for _ in range(n):
    line = list(map(int, input().split()))
    books.append((line[0], np.array(line[1:])))
    total_price += line[0]
    total_scores += np.array(line[1:])

current_scores = total_scores - x
if any(current_scores < 0):
    print(-1)
else:
    books = sorted(books, key=lambda book: book[0])
    while(books):
        book = books.pop()
        if any((current_scores - book[1]) < 0):
            continue
        else:
            total_price -= book[0]
            current_scores -= book[1]
    print(total_price)

Submission status: Wrong Answer

Solution code:
def check(idxs_):
    rikaido = [0 for i in range(m)]
    cost_ = 0
    for i in idxs_:
        for j in range(m):
            rikaido[j] += a[i][j]
        cost_ += c[i]
    for i in range(m):
        if rikaido[i] < x:
            cost_ = 9999999
    return cost_


n, m, x = map(int, input().split())
c = []
a = []
for i in range(n):
    _ = list(map(int, input().split()))
    c.append(_[0])
    a.append(_[1:])

mini = 9999999

for i in range(2 ** n):
    _ = []
    for j in range(n):
        if ((i >> j) & 1):
            _.append(j)
    cost = check(_)
    if cost < mini:
        mini = cost
    # print(mini)

if mini == 99999999:
    mini = -1

print(mini)

Submission status: Wrong Answer

Solution code:
import numpy as np

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



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



ans = 1 << 31

for i in range(2**n):
    tmp = np.zeros(len(caa[0]))
    for j in range(n):
        if i % (2**j):
            tmp += caa[j]
    if min(tmp[1:]) >= x:
        ans = min(ans, tmp[0])

if ans != 1<<31:
    print(int(ans))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np

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



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



ans = 1 << 31

for i in range(2**n):
    tmp = np.zeros(len(caa[0]))
    for j in range(n):
        if i % (2**j):
            tmp += caa[j]
        if min(tmp[1:]) >= x:
            ans = min(ans, tmp[0])

if ans != 1<<31:
    print(int(ans))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import itertools


def check(idxs_):
    rikaido = [0 for i in range(m)]
    cost_ = 0
    for i in idxs_:
        for j in range(m):
            rikaido[j] += a[i][j]
        cost_ += c[i]
    for i in range(m):
        if rikaido[i] < x:
            cost_ = -1
    return cost_


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

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

# 達成できそうか判定
idxs = [i for i in range(n)]
cost = check(idxs)
if cost == -1:
    print(cost)
else:
    minval = 99999999999
    l = [i for i in range(n)]
    for ni in range(n):
        for v in itertools.combinations(l, ni):
            # print(v)
            idxs = list(v)
            cost = check(idxs)
            # print(cost)
            if cost != -1 and cost < minval:
                minval = cost
    print(minval)

Submission status: Wrong Answer

Solution code:
n, m, x = [*map(int, input().split())]
k = []
ans = 10 ** 6
for i in range(n):
    c, *a = [*map(int, input().split())]
    k.append([c, *a])

for i in range(2 ** n):
    cost = 0
    skills = [0] * m
    for j in range(n):
        if ((i >> j) & 1):
            cost += k[j][0]
            for s, t in enumerate(k[j][1:]):
                skills[s] += t
            if all(map(lambda skill: skill >= x, skills)):
                ans = min(ans, cost)
print(-1 if ans == 10 ** 6 else ans)

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
c=[]
a=[]
for i in range(n):
  tmp = list(map(int, input().split()))
  c.append(tmp[0])
  a.append(tmp[1:])
  
result = -1
for i in range(2**n):
  skill = [0]*m
  cost = 0
  for j in range(m):
    if (i >> j) & 1 == 0:
      continue
    cost += c[j]
    for s in range(m):
      skill[s] += a[j][s]
      
  if all(s >= x for s in skill):
    if result == -1:
      result = cost
    else:
      result = min(result,cost)
print(result)

Submission status: Wrong Answer

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

def main():
    N, M, X = map(int, input().split())
    mat = [list(map(int, input().split())) for _ in range(N)]

    ans = 12 * (10 ** 5) +1
    for i in range(1<<N):
        tmp = [0] * (M+1)
        for j in range(N):
            if (i>>j)&1:
                tmp = [x+y for x, y in zip(tmp, mat[j])]
        if all(tmp[k] >= X for k in range(1, M)):
                ans = min(ans, tmp[0])

    print('-1') if ans == 12 * (10 ** 5) +1 else print(ans)
            
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    N, M, X = map(int, input().split())
    mat = [list(map(int, input().split())) for _ in range(N)]

    ans = 12 * (10 ** 5) +1
    for i in range(1<<N):
        tmp = [0] * (M+1)
        for j in range(N):
            if (i>>j)&1:
                for k in range(M+1):
                    tmp[k] += mat[j][k]
                #tmp = [x+y for x, y in zip(tmp, mat[j])]
        if all(tmp[l] >= X for l in range(1, M)):
                ans = min(ans, tmp[0])

    print('-1') if ans == 12 * (10 ** 5) +1 else print(ans)
            
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    N, M, X = map(int, input().split())
    mat = [list(map(int, input().split())) for _ in range(N)]

    ans = 12 * (10 ** 5) +1
    for i in range(1<<N):
        tmp = [0] * (M+1)
        for j in range(N):
            if (i>>j)&1:
                tmp = [x+y for x, y in zip(tmp, mat[j])]
        if all(tmp[i] >= X for i in range(1, M)):
                ans = min(ans, tmp[0])

    print('-1') if ans == 12 * (10 ** 5) +1 else print(ans)
            
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    N, M, X = map(int, input().split())
    mat = [list(map(int, input().split())) for _ in range(N)]

    ans = 12 * (10 ** 5) +1
    for i in range(1<<N):
        tmp = [0] * (M+1)
        for j in range(N):
            if (i>>j)&1:
                tmp = [x+y for x, y in zip(tmp, mat[j])]
        flag = True
        for i in range(1, M):
            if tmp[i] < X:
                break
        else:
            ans = min(ans, tmp[0])

    print('-1') if ans == 12 * (10 ** 5) +1 else print(ans)
            
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    N, M, X = map(int, input().split())
    mat = [list(map(int, input().split())) for _ in range(N)]

    ans = 12 * (10 ** 5) +1
    for i in range(1<<N):
        tmp = [0] * (M+1)
        for j in range(N):
            if (i>>j)&1:
                tmp = [x+y for x, y in zip(tmp, mat[j])]
        flag = True
        for i in range(1, M):
            if tmp[i] < X:
                break
        ans = min(ans, tmp[0])

    print('-1') if ans == 12 * (10 ** 5) +1 else print(ans)
            
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    N, M, X = map(int, input().split())
    mat = [list(map(int, input().split())) for _ in range(N)]

    ans = float('inf')
    for i in range(1<<N):
        tmp = [0] * (M+1)
        for j in range(N):
            if (i>>j)&1:
                tmp = [x+y for x, y in zip(tmp, mat[j])]
        flag = True
        for i in range(1, M):
            if tmp[i] < X:
                flag = False
        if flag:
            ans = min(ans, tmp[0])
    print('-1') if ans == float('inf') else print(ans)
            
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    N, M, X = map(int, input().split())
    mat = [list(map(int, input().split())) for _ in range(N)]

    ans = float('inf')
    for i in range(1<<N):
        tmp = [0] * (M+1)
        for j in range(N):
            if (i>>j)&1:
                tmp = [x+y for x, y in zip(tmp, mat[j])]
        flag = True
        for i in range(1, M):
            if tmp[i] < X:
                flag = False
        if flag:
            ans = min(ans, tmp[0])
    print(-1) if ans == float('inf') else print(ans)
            
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

a,b,c=ml()
cost=[]
for i in range(a):
    cost.append(ll())
ans=1e18    
flag=1
for i in range(1<<a):
    val=[0]*(b+1)
    for j in range(a):
        if(i&(1<<j)):
            for k in range(b+1):
                val[k]+=cost[j][k]    
    f=0
    for j in val:            
        if(j<c):
            f=1
            break
    if f==0:
        flag=0
        ans=min(val[0],ans)
if(flag):
    print(-1)
else:    
    print(ans)

Submission status: Wrong Answer

Solution code:
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

a,b,c=ml()
cost=[]
for i in range(a):
    cost.append(ll())
ans=1e18    
flag=1
for i in range(1<<a):
    val=[0]*b
    for j in range(a):
        if(i&(1<<j)):
            for k in range(b):
                val[k]+=cost[j][k]    
    f=0
    for j in val:            
        if(j<c):
            f=1
            break
    if f==0:
        flag=0
        ans=min(val[0],ans)
if(flag):
    print(-1)
else:    
    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

min_C = np.inf
conbi = None
m = 2**N

for i in range(m):
  tmp = []
  for _ in range(N):
    tmp.append(i%2)
    i //= 2
  
  sum_array = np.sum(array[np.where(tmp)], axis=0)
  #print(tmp)
  if np.all(sum_array>=X):
    if sum_array[0] < min_C:
      min_C = sum_array[0]
      conbi = tmp
      
if conbi is None:
  print(-1)
else:
  print(min_C)

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
C = []
A = []
ans = float("inf")

for n in range(N):
    temp = list(map(int, input().split()))
    C.append(temp[0])
    A.append(temp[1:])
    
for i in range(2**N):
    mny = 0
    score = [0]*M
    for j in range(N):
        if i&(j**2)>0:
            mny += C[j]
            for k in range(M):
                score[k] += A[j][k]
    if min(score)>=X:
        ans = min(ans, mny)

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

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
a = [list(map(int,input().split())) for x in range(n)]
total = [0]*(m+1)
flg = False
mflg = True
min_num = 10**5+1
for i in range(1,2**n):
    for j in range(n):
        if ((i >> j) & 1):
            total = [x + y for (x, y) in zip(a[j], total)]
    for k in range(m):
        if total[1+k] < x:
            mflg = False
            break
    if mflg and total[0] < min_num:
        min_num = total[0]
        flg = True
    total = [0]*(m+1)
    mflg = True
if flg:
    print(min_num)
else:
    print('-1')

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
a = [list(map(int,input().split())) for x in range(n)]
total = [0]*(m+1)
flg = False
mflg = True
min_num = 10**5+1
for i in range(1,2**n):
    for j in range(n):
        if ((i >> j) & 1):
            total = [x + y for (x, y) in zip(a[j], total)]
    for k in range(m):
        if total[1+k] < x:
            mflg = False
            break
    if mflg and total[0] < min_num:
        min_num = total[0]
        flg = True
    total = [0]*(m+1)
    mflg = True
if flg:
    print(min_num)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
N,M,X = map(int,input().split())
C=[0 for i in range(N)]
A=[[] for i in range(N)]
min_cost=10000000000
for i in range(N):
    C[i],*A[i]=map(int,input().split())
for i in range(1<<N):
    L=[0 for i in range(M)]
    cost=0
    for j in range(N):
        if 1&(i>>j):
            for k in range(M):
                L[k]+=A[j][k]
            cost+=C[j]
    if min(L)>=X:
      min_cost=min(min_cost,cost)
print(min_cost)

Submission status: Wrong Answer

Solution code:
def Skill_Up():
    condition = input()
    condition_list = condition.split()
    N = int(condition_list[0])
    M = int(condition_list[1])
    X = int(condition_list[2])
    
    text_info=[]
    for i in range(0, N):
        text_book = input()
        text_info_str = text_book.split()
        text_book_int = []
        for j in text_info_str:
            text_book_int.append(int(j))
        text_info.append(text_book_int)
    
    text_effective = []
    for i in text_info:
        effective = 0
        for j in range(1, M+1):
            effective += i[j]
        effective =(effective * (10**5) ) / i[0]
        text_effective.append(effective)
    
    for i in range(0, N):
        for j in range(0, N - i - 1):
            if text_effective[j] < text_effective[j+1]:
                text_effective[j], text_effective[j+1] = text_effective[j+1], text_effective[j]
                text_info[j], text_info[j+1] = text_info[j+1], text_info[j]
    
    skill_level = []
    skill_check = []
    for j in range(0, M+1):
        skill_level.append(0)
        skill_check.append(False)
    
    is_clear = False
    for i in range(0, N):
        for j in range(0, M+1):
            skill_level[j] += text_info[i][j]
            if skill_level[j] >= X:
                skill_check[j] = True
        for j in range(0, M+1):
            if skill_check[j] is False:
                is_clear = False
                break
            is_clear = True
        if is_clear:
            print(skill_level[0])
            return
    
    if is_clear is False:
        print(-1)
        return
    
Skill_Up()

Submission status: Wrong Answer

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


C=[]
A=[]
for i in range(N):
    a=[int(x) for x in input().split()]
    C.append(a[0])
    A.append(a[1:])
#
def combination(list_, length):
    #print(list_, length)
    if length == 2:
        list_com = [[list_[0], list_[1]],[list_[1], list_[0]]]
        return list_com
    else:
        list_com=[]
        for i in range(length):
            out_i = [list_[j]for j in range(length)if i!=j]
            list_com_i = combination(out_i, len(out_i))
            
            for j in range(len(list_com_i)):
                list_c = [list_[i]]
                list_c.extend(list_com_i[j])
                list_com.append(list_c)
        return list_com

num = [i for i in range(N)]
all_com = combination(num, N)
#print(N,num,all_com)

cost_min = 10000000
for combi in all_com:
    #print(combi)
    cost=0
    skil = [0 for j in range(M)]
    clear=M
    
    for j in range(N):  #len(combi)=N
        if clear != 0:
            cost += C[combi[j]]
            clear = M
            for k in range(M):
                skil[k]+=A[combi[j]][k]
            #check
                if skil[k]>=X:
                    clear = clear-1
    #print(cost)
    if clear == 0:
        if cost < cost_min:
            cost_min = cost

if cost_min == 10000000:
    cost_min = -1

#for i in range(N):
    #print(C[i], A[i])
print(cost_min)

Submission status: Wrong Answer

Solution code:
n, m, x = list(map(int, input().split()))
lists = []
result_price = 0
existed = False

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

for i in range(n):
  result_price += lists[i][0]
for i in range(1 << n):
  flag = True
  scores = [0] * m
  tmp_price = 0
  for j in range(n):
    if i & (1 << j):
      for k in range(m):
        scores[k] += lists[j][k+1]
      tmp_price += lists[j][0]
  for l in range(m):
    if scores[l] < x:
      flag = False
      break
  if flag and (result_price > tmp_price):
    print(i)
    existed = True
    result_price = tmp_price
if existed:
  print(result_price)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
n, m, x =map(int,input().split())
s = [list(map(int, input().split())) for _ in range(n)]
ans = 1000000
for i in range(2 ** n):
  bag = [0]*(m+1)
  for j in range(n):
    if ((i>>j)&1):
        for _ in range(m+1):
          bag[_] += s[j][_]
  ##print(bag)
  if (min(bag[1:]) >= x and ans > bag[0]):
    ans = bag[0]
    
if ans == 1000000:
  print("-1")
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
def Skill_Up():
    condition = input()
    condition_list = condition.split()
    N = int(condition_list[0])
    M = int(condition_list[1])
    X = int(condition_list[2])
    
    text_info=[]
    for i in range(0, N):
        text_book = input()
        text_info_str = text_book.split()
        text_book_int = []
        for j in text_info_str:
            text_book_int.append(int(j))
        text_info.append(text_book_int)
    
    text_effective = []
    for i in text_info:
        effective = 0
        for j in range(1, M+1):
            effective += i[j]
        effective /= i[0]
        text_effective.append(effective)
    
    for i in range(0, N):
        for j in range(0, N - i - 1):
            if text_effective[j] < text_effective[j+1]:
                text_effective[j], text_effective[j+1] = text_effective[j+1], text_effective[j]
                text_info[j], text_info[j+1] = text_info[j+1], text_info[j]
    
    skill_level = []
    skill_check = []
    for j in range(0, M+1):
        skill_level.append(0)
        skill_check.append(False)
    
    is_clear = False
    for i in range(0, N):
        for j in range(0, M+1):
            skill_level[j] += text_info[i][j]
            if skill_level[j] >= X:
                skill_check[j] = True
        for j in range(0, M+1):
            if skill_check[j] is False:
                is_clear = False
                break
            is_clear = True
        if is_clear:
            print(skill_level[0])
            return
    
    if is_clear is False:
        print(-1)
        return
    
Skill_Up()

Submission status: Wrong Answer

Solution code:
def Skill_Up():
    condition = input()
    condition_list = condition.split()
    N = int(condition_list[0])
    M = int(condition_list[1])
    X = int(condition_list[2])
    
    text_info=[]
    for i in range(0, N):
        text_book = input()
        text_info_str = text_book.split()
        text_book_int = []
        for j in text_info_str:
            text_book_int.append(int(j))
        text_info.append(text_book_int)
    
    text_effective = []
    for i in text_info:
        effective = 0
        for j in range(1, M+1):
            effective += i[j]
        effective /= i[0]
        text_effective.append(effective)
    
    for i in range(0, N):
        for j in range(0, N - i - 1):
            if text_effective[j] < text_effective[j+1]:
                text_effective[j], text_effective[j+1] = text_effective[j+1], text_effective[j]
                text_info[j], text_info[j+1] = text_info[j+1], text_info[j]
    
    skill_level = []
    skill_check = []
    for j in range(0, M+1):
        skill_level.append(0)
        skill_check.append(False)
    
    is_clear = False
    for i in range(0, N):
        for j in range(0, M+1):
            skill_level[j] += text_info[i][j]
            if skill_level[j] >= X:
                skill_check[j] = True
        for j in range(0, M+1):
            if skill_check[j] is False:
                is_clear = False
                break
            is_clear = True
    
    if is_clear:
        print(skill_level[0])
    else:
        print(-1)
    
Skill_Up()

Submission status: Wrong Answer

Solution code:
import sys
n,m,x=map(int,input().split())
A=[]
for i in range(n):
    ca=list(map(int,input().split()))
    A.append(ca)
ans=10**7

for i in range(2**n):#n冊をそれぞれ選ぶか選ばないか
    tmp=[0]*m
    cost=0
    for j in range(n):#ある選び方
        if (1<<j)&i:
            cost+=A[j][0]
            for k in range(m):
                tmp[k]+=A[j][k+1]
    for l in range(m):#理解度がx以上か判定
        if tmp[l]<x:
            break
    ans=min(ans,cost)#すべてのアルゴリズムの目標理解度を満たすとき
if ans==10**7:#ansが更新されない場合
    ans=-1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
n,m,x=map(int,input().split())
A=[]
for i in range(n):
    ca=list(map(int,input().split()))
    A.append(ca)
ans=10**20

for i in range(2**n):#n冊をそれぞれ選ぶか選ばないか
    tmp=[0]*m
    cost=0
    for j in range(n):#ある選び方
        if (1<<j)&i:
            cost+=A[j][0]
            for k in range(m):
                tmp[k]+=A[j][k+1]
    for l in range(m):#理解度がx以上か判定
        if tmp[l]<x:
            break
        else:
            ans=min(ans,cost)
if ans==10**7:#ansが更新されない場合
    ans=-1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
n,m,x=map(int,input().split())
A=[]
for i in range(n):
    ca=list(map(int,input().split()))
    A.append(ca)
ans=10*20

for i in range(2**n):#n冊をそれぞれ選ぶか選ばないか
    tmp=[0]*m
    cost=0
    for j in range(n):#ある選び方
        if (1<<j)&i:
            cost+=A[j][0]
            for k in range(m):
                tmp[k]+=A[j][k+1]
    for l in range(m):#理解度がx以上か判定
        if tmp[l]<x:
            break
        else:
            ans=min(ans,cost)
if ans==10**7:#ansが更新されない場合
    ans=-1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
n,m,x=map(int,input().split())
A=[]
for i in range(n):
    ca=list(map(int,input().split()))
    A.append(ca)
ans=10**7

for i in range(2**n):#n冊をそれぞれ選ぶか選ばないか
    tmp=[0]*m
    cost=0
    for j in range(n):#ある選び方
        if (1<<j)&i:
            cost+=A[j][0]
            for k in range(m):
                tmp[k]+=A[j][k+1]
    for l in range(m):#理解度がx以上か判定
        if tmp[l]<x:
            break
        else:
            ans=min(ans,cost)
if ans==10**7:#ansが更新されない場合
    ans=-1
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
n, m, x = list(map(int,input().split()))
c = []
for i in range(n):
    c.append(list(map(int,input().split())))
mn = 0
for bn in itertools.product([0,1], repeat=n):
    money = 0
    skills = [0]*m
    for j in range(n):
        if bn[j] == 1:
            money += c[j][0]
            for k in range(m):
                skills[k] += c[j][k+1]
    if all([y > x for y in skills]):
        if mn == -1:
            mn = money
        elif money < mn:
            mn = money
print(mn)

Submission status: Wrong Answer

Solution code:
N,M,X = map(int,input().split())
d=[]
ans = []
for i in range(N):
    l=list(map(int,input().split()))
    d.append(l)
print(d)
for i in range(2**N):
    u=[0]*M
    price=0
    for j in range(N):
           if ((i>>j) & 1):
                price+=d[j][0]
                for k in range(M):
                    u[k]+=d[j][k+1]
    if all(x>=X for x in u):
        ans.append(price)
print(min(ans) if len(ans) > 0 else -1)