TnT/Multi_CodeNet4Repair huggingface dataset:
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.

Submission attempts (in order):
n,m,x = map(int,input().split())

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

res=float('inf')

for i in range(2**n):
  sc=0
  a=[0]*m
  for j in range(n):
    if ((i >> j) & 1) :
      sc=+ca[j][0]
      a+=ca[j][1:]
  if min(a)>=x:
    res=min (sc,res)

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


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

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

res=float('inf')

for i in range(2**n):
  sc=0
  a=[0]*m
  for j in range(n):
    if ((i >> j) & 1) :
      sc+=ca[j][0]
      for k in range(m):
        a[k]+=ca[j][k+1]
  if min(a)>=x:
    res=min(sc,res)

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


Verdicts: Runtime Error

Accepted
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.

Submission attempts (in order):
(n,m,x)=map(int,input().split())
c=list()
a=list()
for i in range(n):
  line=list(map(int,input().split()))
  c.append(line.pop(0))
  a.append(line)

result=list()
for i in range(2**n):
  total=[0]*m
  cost=0
  for k in range(n):
    if bin(i)[k]=="1":
      total+=a[k]
      cost+=int(c[k])
  if total>=[x]*m:
    result.append(cost)

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

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

for i in range(2**n):
  total=[0]*m
  cost=0
  for k in range(n):
    if int(bin(i)[k])==1:
      total+=a[k]
      cost+=c[k]
  if total>=[x]*m:
    result.append(cost)

if result!=None:
  print(min(cost))
else:
  print(-1)

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

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

a=np.array(a)
result=np.array([[0]*(m+1)])
for i in range(n):
    l=list()
    for j in range(len(result)):
        l.append(a[i]+result[j])
        l.append(result[j])
    result=np.array(l)

c=list()
h=[x]*m
for line in result:
    if np.all(line[1:]>=h):
        c.append(line[0])
if len(c)==0:
    print(-1)
else:
    print(min(c))

Verdicts: Runtime Error

Runtime Error

Accepted
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.

Submission attempts (in order):
n,m,x=map(int,input().split())
l=[]

for i in range(n):
    a=list(map(int,input().split()))
    l.append(a)
print(l)
ans=99999999
for i in range(2 ** n):
    bag = []
    for j in range(n):  
        if ((i >> j) & 1): 
            bag.append(l[j])  
    skill=[0]*m
    enou=[0]*m
    mone=0
    for sub in bag:
        mone+=sub[0]
        for kk in range(1,m):
            skill[kk-1]+=sub[kk]
            if skill[kk-1]>=x:
                enou[kk-1]+=1
    if sum(enou)==m:
        if ans>mone:
            ans=mone
if ans==99999999:
    print(-1)
else:
    print(ans)

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

for i in range(n):
    a=list(map(int,input().split()))
    l.append(a)
ans=99999999
for i in range(2 ** n):
    bag = []
    for j in range(n):  
        if ((i >> j) & 1): 
            bag.append(l[j])  
    skill=[0]*m
    enou=[0]*m
    mone=0
    for sub in bag:
        mone+=sub[0]
        for kk in range(1,m+1):
            skill[kk-1]+=sub[kk]
            if skill[kk-1]>=x:
                enou[kk-1]+=1
    if 0 not in enou:
        if ans>mone:
            ans=mone
if ans==99999999:
    print(-1)
else:
    print(ans)

Verdicts: Wrong Answer

Accepted
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.

Submission attempts (in order):
import numpy as np
n, m, x = map(int, input().split())
Book = [list(map(int, input().split())) for _ in range(n)]
select = [np.array([])]*(2**n)
cost = [0]*(2**n)
skill = [np.array([0]*m)]*(2**n)
cost2 = []
for i in range(2**n):
    for j in range(n):
        if (i >> j) & 1:
            cost[i] += Book[j][0]
            skill[i] += np.array(Book[j])[1:m+1]
    if np.min(skill[i]) >= x:
        cost2.append(cost[i])
if len(cost2) > 0:
    print(min(cost2))
else:
    print(-1)

import numpy as np
n, m, x = map(int, input().split())
Book = [list(map(int, input().split())) for _ in range(n)]
cost = [0 for _ in range(2**n)]
skill = [np.zeros(m) for _ in range(2**n)]
cost2 = []
for i in range(2**n):
    for j in range(n):
        if (i >> j) & 1:
            cost[i] += Book[j][0]
            skill[i] += np.array(Book[j])[1:m+1]
    if np.min(skill[i]) >= x:
        cost2.append(cost[i])
if cost2:
    print(min(cost2))
else:
    print(-1)

Verdicts: Wrong Answer

Accepted
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.

Submission attempts (in order):
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)

import itertools
n, m, x = list(map(int,input().split()))
c = []
for i in range(n):
    c.append(list(map(int,input().split())))
mn = -1
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)

Verdicts: Wrong Answer

Accepted
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.

Submission attempts (in order):
#coding :utf-8
import numpy as np

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

suma=sum(a[0][])
print(suma,a)

#coding :utf-8

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

C=[]
A=[]
for i in range(N):
  t=list(map(int,input().split()))
  C.append(t[0])
  A.append(t[1:])
result=-1

for i in range(1<<N):
  t=[0]*M
  c=0
  for j in range(N):
    if ((i>>j) & 1==0):
      continue
    c+=C[j]
    for k in range(M):
      t[k]+=A[j][k]
    
  
  if all(x>=X for x in t):
    if result==-1:
      result=c
    else:
      result=min(result,c)

print(result)

Verdicts: Runtime Error

Accepted
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.

Submission attempts (in order):
N, M, X = map(int,input().split())

CAM = list([list(map(int,input().split())) for i in range(N)])
# print(CAM)
minn = 10**18
b = False

for i in range(2 ** N):
  s = 0
  am = []

  for j in range(N):  
      if ((i >> j) & 1):  
        am.append(CAM[j])

  j = False
  sss = [0] * (M+1)
  for kk in range(len(am)):
    s += am[kk][0]
    for m in range(0, M):
      sss[m+1] += am[kk][m+1]
  
  if len([i for i in sss[1:] if i >= X] ) == len(sss[1:]):
    b = True
    minn = min(s,minn)
  
  print(sss)
  # if x >= X and y >= X and z >= X:
  
  #   b = True

print(minn if b == True else -1)

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

CAM = list([list(map(int,input().split())) for i in range(N)])
# print(CAM)
minn = 10**18
b = False

for i in range(2 ** N):
  s = 0
  am = []

  for j in range(N):  
      if ((i >> j) & 1):  
        am.append(CAM[j])

  j = False
  sss = [0] * (M+1)
  for kk in range(len(am)):
    s += am[kk][0]
    for m in range(0, M):
      sss[m+1] += am[kk][m+1]
  
  if len([i for i in sss[1:] if i >= X] ) == len(sss[1:]):
    b = True
    minn = min(s,minn)
  
  # print(sss)
  # if x >= X and y >= X and z >= X:
  
  #   b = True

print(minn if b == True else -1)

Verdicts: Wrong Answer

Accepted
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.

Submission attempts (in order):
n,m,x=map(int,input().split())
c=[list(map(int,input().split())) for i in range(n)]
ans=10**9

for i in range(2**n):
  b=[0]*m
  count=0
  en=0
  for j in range(n):
    if (i>>j)&1:
      en=en+c[j][0]
      for f in range(m):
        b[f]+=c[j][f+1]
      for f in range(m):
        if b[f]>=x:
          count+=1
          print(b[f])
        if count==m:
          if en<ans:
            ans=en

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

n,m,x=map(int,input().split())
a=[]
c=[]
inf=10**9
result=inf
for i in range(n):
    b=list(map(int,input().split()))
    c.append(b[0])
    a.append(b[1:])
    
for i in range(1<<n):
  cnt=0
  rikaido=[0]*m
  for j in range(n):
    if (i>>j)&1:
      for k in range(m):
        rikaido[k]+=a[j][k]
        cnt+=c[j]
    else:
      pass
  if min(rikaido)>=x:
    result=min(result,cnt)

if result==inf:
  print(-1)
else:
  print(result)

n,m,x=map(int,input().split())
a=[]
c=[]
inf=10**9
result=inf
for _ in range(n):
    books=list(map(int,input().split()))
    c.append(books[0])
    a.append(books[1:])
    
for i in range(1<<n):
  cnt=0
  rikaido=[0]*m
  for j in range(n):
    if (i>>j)&1:
      for k in range(m):
        rikaido[k]+=a[j][k]
      cnt+=c[j]
    else:
      pass
  if min(rikaido)>=x:
    result=min(result,cnt)

if result==inf:
  print(-1)
else:
  print(result)


Verdicts: Wrong Answer

Wrong Answer

Accepted
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.

Submission attempts (in order):
n,m,x = (int(x) for x in input().split())

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

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

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

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

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

Verdicts: Wrong Answer

Accepted
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.

Submission attempts (in order):
from itertools import product
n, m, x = map(int, input().split())
costs = []
gets = []
for i in range(n):
    cost, *argo = map(int, input().split())
    costs.append(cost)
    gets.append(argo)

    
bits_list = list(product([0,1], repeat=n))
min_cost = float('inf')
cnt = 0
for bits in bits_list:
    tmp_cost = 0
    tmp_argo = [0] * m
    for i, v in enumerate(bits):
        if v:
            tmp_cost += costs[i]
            for j, p in enumerate(gets[i]):
                tmp_argo[j] += p
                
    if all(map(lambda X:X>x, tmp_argo)):
        min_cost = min(min_cost, tmp_cost)
        cnt = 1
if cnt:
    print(min_cost)
else:
    print(-1)

from itertools import product
n, m, x = map(int, input().split())
costs = []
gets = []
for i in range(n):
    cost, *argo = map(int, input().split())
    costs.append(cost)
    gets.append(argo)

    
bits_list = list(product([0,1], repeat=n))
min_cost = float('inf')
cnt = 0
for bits in bits_list:
    tmp_cost = 0
    tmp_argo = [0] * m
    for i, v in enumerate(bits):
        if v:
            tmp_cost += costs[i]
            for j, p in enumerate(gets[i]):
                tmp_argo[j] += p
                
    if all(map(lambda X:X>=x, tmp_argo)):
        min_cost = min(min_cost, tmp_cost)
        cnt = 1
if cnt:
    print(min_cost)
else:
    print(-1)

Verdicts: Wrong Answer

Accepted
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.

Submission attempts (in order):
import numpy as np
from itertools import product
INF = 10**9

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

choose = [True, False]

min_price = INF

for s in product([True, False], repeat=N):
    price = 0
    knowledge = np.zeros(M)
    for i in range(N):
        if s >> i & 1:
            knowledge += A[i]
            price += C[i]
    if np.any(knowledge < X):
        continue
    if min_price == -1:
        min_price = price
    min_price = min(min_price, price)

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


import numpy as np
from itertools import product
INF = 10**9

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

choose = [True, False]

min_price = INF

for s in product([True, False], repeat=N):
    price = 0
    knowledge = np.zeros(M)
    for i in range(N):
        if s[i]:
            knowledge += A[i]
            price += C[i]
    if np.any(knowledge < X):
        continue
    if min_price == -1:
        min_price = price
    min_price = min(min_price, price)

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


Verdicts: Runtime Error

Accepted
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.

Submission attempts (in order):
from sys import stdin
n, m, x = [int(x) for x in stdin.readline().rstrip().split()]
c = [[int(y) for y in x.rstrip().split()] for x in stdin.readlines()]

c.sort()
mi = -1

for i in range(len(c)-1):
    _li = [x for x in c[i] if x != c[i][0]]
    mon = c[i][0]

    for j in range(i + 1, len(c)):
        li = [_li[k] + c[j][k + 1] for k in range(len(_li))]
        mon += c[j][0]
        if sum(1 for k in li if k >= x) == m:
            if mi > mon or mi == -1:
                mi = mon
            break
        else:
            _li = li


print(mi)

from sys import stdin
import itertools

n, m, x = [int(x) for x in stdin.readline().rstrip().split()]
c = [[int(y) for y in x.rstrip().split()] for x in stdin.readlines()]
c.sort()
mi = -1
r = 0

for j in range(1, m + 1):
    li = [x[j] for x in c]
    li.sort(reverse=True)
    for i in range(len(li)):
        if sum(li[:i]) >= x:
            r = max(r, i)
            break

for h in range(r,n):
    for i in itertools.combinations(c, h):
        cnt = [0] * m
        mon = 0
        for j in i:
            cnt = [cnt[k]+j[k+1] for k in range(len(cnt))]
            mon += j[0]
            print(cnt)            
            if sum(1 for k in cnt if k >= x) == m:
                if mi > mon or mi == -1:

                    mi = mon
                break

print(mi)


from sys import stdin
import itertools

n, m, x = [int(x) for x in stdin.readline().rstrip().split()]
c = [[int(y) for y in x.rstrip().split()] for x in stdin.readlines()]
c.sort()
mi = -1
r = 0

for j in range(1, m + 1):
    li = [x[j] for x in c]
    li.sort(reverse=True)
    for i in range(1, len(li) + 1):
        if sum(li[:i]) >= x:
            r = max(r, i)
            break

for h in range(r, n + 1):
    for i in itertools.combinations(c, h):
        cnt = [0] * m
        mon = 0
        for j in i:
            cnt = [cnt[k]+j[k+1] for k in range(len(cnt))]
            mon += j[0]
            if sum(1 for k in cnt if k >= x) == m:
                if mi > mon or mi == -1:

                    mi = mon
                break

print(mi)


Verdicts: Wrong Answer

Wrong Answer

Accepted
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.

Submission attempts (in order):
# ABC 167 C
N,M,X = map(int,input().split())
C =[]
for m in range(N):
    C.append([int(i) for i in input().split()])
C.sort(key=lambda x:x[0])

from itertools import combinations
import numpy as np


ans = 10**5 +1

for m in range(1,N+1):
    P=list(combinations(C,m))
    print(P)
    tmp =np.sum(P,axis=1)
    for t in tmp:

        if min(t[1:])>=X and ans > t[0]:
            ans = t[0]
        print(t)
        
          
if min(t[1:])<X:
    print(-1)
else:
    print(ans)

# ABC 167 C
N,M,X = map(int,input().split())
C =[]
for m in range(N):
    C.append([int(i) for i in input().split()])
C.sort(key=lambda x:x[0])

from itertools import combinations
import numpy as np

ans = 10**5 +1

for m in range(1,M+1):
    P=list(combinations(C,m))
    tmp =np.sum(P,axis=1)
    if ans < tmp[0,0]:
        print(ans)
        exit()
    elif min(tmp[0,1:])>=X and ans > tmp[0,0]:
        ans = tmp[0,0]


if min(tmp[0,1:])<X:
    print(-1)
else:
    print(ans)


# ABC 167 C
N,M,X = map(int,input().split())
C =[]
for m in range(N):
    C.append([int(i) for i in input().split()])
C.sort(key=lambda x:x[0])

from itertools import combinations
import numpy as np


ans = 10**5 +1

for m in range(1,N+1):
    P=list(combinations(C,m))
    print(P)
    tmp =np.sum(P,axis=1)
    for t in tmp:

        if min(t[1:])>=X and ans > t[0]:
            ans = t[0]

        
          
if min(t[1:])<X:
    print(-1)
else:
    print(ans)

N,M,X =map(int,input().split())
A =[]
for m in range(N):
    A.append([int(j) for j in input().split()])
ans = 10**10
import numpy as np
from itertools import product,compress
for i in list(product([True,False],repeat=N)):
    tmp = np.sum(list(compress(A, i)),axis=0)
    if type(tmp)!=np.float64:
    	if tmp[0]< ans and min(tmp[1:])>=X:
            ans =tmp[0]
if ans ==10**10:
    print(-1)
else:
    print(ans)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
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.

Submission attempts (in order):
import itertools
import copy
n,m,x = map(int,input().split())
ans = [0 for i in range(m)]
books = []
answer = 1000000000000000000000
for i in range(n):
    books.append(list(map(int,input().split())))
for i in range(n):
    stock = list(list(itertools.combinations([num for num in range(n)], i+1)))
    for j in stock:
        cost = 0
        ans = [0 for i in range(m)]
        for k in j:
            for e,l in enumerate(books[k]):
                if e == 0:
                    cost += l
                else:
                    ans[e-1] += l
            if min(ans) >= x and cost < answer:
                answer = copy.deepcopy(cost)
if answer = 1000000000000000000000:
    print(-1)
else:
    print(answer)


import itertools
import copy
n,m,x = map(int,input().split())
ans = [0 for i in range(m)]
books = []
answer = 1000000000000000000000
for i in range(n):
    books.append(list(map(int,input().split())))
for i in range(n):
    stock = list(list(itertools.combinations([num for num in range(n)], i+1)))
    for j in stock:
        cost = 0
        ans = [0 for i in range(m)]
        for k in j:
            for e,l in enumerate(books[k]):
                if e == 0:
                    cost += l
                else:
                    ans[e-1] += l
            if min(ans) >= x and cost < answer:
                answer = copy.deepcopy(cost)
if answer == 1000000000000000000000:
    print(-1)
else:
    print(answer)


Verdicts: Runtime Error

Accepted
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.

Submission attempts (in order):
n, m, x = map(int, input().split(' '))
input_lists = [list(map(int, input().split(' '))) for _ in range(n)]
 
comb = []
for i in range(2 ** n):
    tmp = []
    for j in range(n):
        if ((i >> j) & 1):
            tmp.append(input_lists[j])
    comb.append(tmp)

result = -1
for i in range(len(comb)):
    understand = [0]*m
    total_fee = 0
    for j in range(len(comb[i])):
        total_fee += comb[i][j][0]
        for k in range(1, m):
            understand[k] += comb[i][j][k]
    boolean = True
    for j in range(m):
        if all(t < x for t in understand):
            boolean = False
    if boolean and (result == -1 or result > understand[0]):
        result = total_fee
 
print(result)

n, m, x = map(int, input().split(' '))
input_lists = [list(map(int, input().split(' '))) for _ in range(n)]
 
comb = []
for i in range(2 ** n):
    tmp = []
    for j in range(n):
        if ((i >> j) & 1):
            tmp.append(input_lists[j])
    comb.append(tmp)

result = -1
for i in range(len(comb)):
    understand = [0]*m
    total_fee = 0
    for j in range(len(comb[i])):
        total_fee += comb[i][j][0]
        for k in range(m):
            understand[k] += comb[i][j][k+1]
    if all(t >= x for t in understand) and (result == -1 or result > total_fee):
        result = total_fee
 
print(result)

Verdicts: Wrong Answer

Accepted
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.

Submission attempts (in order):
N,M,X=map(int,input().split())
CA=[list(map(int,input().split())) for _ in range(N)]
print(CA)
max_=10**16
ans=max_
for bit in range(2**N):
  check=[0]*M
  ans_=0
  for i in range(N):
    if bit>>i&1:
      ans_+=CA[i][0]
      for j in range(M):
        check[j]+=CA[i][j+1]
  if all([k>=X for k in check]):
    ans=min(ans,ans_)
print(ans if ans!=max_ else -1)


N,M,X=map(int,input().split())
CA=[list(map(int,input().split())) for _ in range(N)]
max_=10**16
ans=max_
for bit in range(2**N):
  check=[0]*M
  ans_=0
  for i in range(N):
    if bit>>i&1:
      ans_+=CA[i][0]
      for j in range(M):
        check[j]+=CA[i][j+1]
  if all([k>=X for k in check]):
    ans=min(ans,ans_)
print(ans if ans!=max_ else -1)


Verdicts: Wrong Answer

Accepted
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.

Submission attempts (in order):
import numpy as np
import itertools
N, M, X = (int(i) for i in input().split())
Y = np.zeros((N, M+1))
for i in range(N):
    Y[i,:] = [int(i) for i in input().split()]
C = Y[:,0]
A = np.matrix(Y[:,1:])
res = np.inf
f = '0'+str(N)+'b'
for i in range(2**N):
    z = np.array([int(s) for s in list(format(i, f))])
    cost = z @ C
    skill = z * A
    if (skill >= X).all() and (cost < res):
        res = cost
if np.isinf(res):
    print(-1)
else:
    print(res)

import numpy as np
import itertools
N, M, X = (int(i) for i in input().split())
Y = np.zeros((N, M+1))
for i in range(N):
    Y[i,:] = [int(i) for i in input().split()]
C = Y[:,0]
A = np.matrix(Y[:,1:])
res = np.inf
f = '0'+str(N)+'b'
for i in range(2**N):
    z = np.array([int(s) for s in list(format(i, f))])
    cost = z @ C
    skill = z * A
    if (skill >= X).all() and (cost < res):
        res = cost
if np.isinf(res):
    print(-1)
else:
    print(int(res))

Verdicts: Wrong Answer

Accepted
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.

Submission attempts (in order):
def solve(i, cost, know, x, a):
    global res
    if i == len(a):
        for j in range(m):
            if know[j] < x:
                return
        res = min(res, cost)
        return
    solve(i + 1, cost, know, x, a)
    for j in range(m):
        know[j] += a[i][j + 1]
    solve(i + 1, cost + a[i][0], know, x, a)
    for j in range(m):
        know[j] -= a[i][j + 1]
fin = open('input.txt', 'r')
n, m, x = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for j in range(n)]
know = [0] * (m)
res = 10 ** 7
solve(0, 0, know, x, a)
print(res if res != 10 ** 7 else - 1)

def solve(i, cost, know, x, a):
    global res
    if i == len(a):
        for j in range(m):
            if know[j] < x:
                return
        res = min(res, cost)
        return
    solve(i + 1, cost, know, x, a)
    for j in range(m):
        know[j] += a[i][j + 1]
    solve(i + 1, cost + a[i][0], know, x, a)
    for j in range(m):
        know[j] -= a[i][j + 1]
n, m, x = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for j in range(n)]
know = [0] * (m)
res = 10 ** 7
solve(0, 0, know, x, a)
print(res if res != 10 ** 7 else - 1) 

Verdicts: Runtime Error

Accepted
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.

Submission attempts (in order):
A,B,C,K=(int(x) for x in input().split())

if(K<=A+B):
    print(A)
if(K>A+B):
    print(A-(K-A-B))

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

for s in range(1<<n):
  cost=0
  d=[0]*m
  for i in range(n):
    if(s>>i&1):
      cost+=c[i]
      for j in range(m):
        d[j]+=a[i][j]
  ok=True
  for j in range(m):
    if(d[j]<x):
      ok=False
  if ok:
    ans=min(ans,cost)
if ans==INF:
  print(-1)
else:
  print(ans)


Verdicts: Runtime Error

Accepted
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.

Submission attempts (in order):
import numpy as np
import itertools
N, M, K = map(int, input().split())
Q = [np.asarray(input().split(), dtype=int) for i in range(N)]
min_cost = 10**9
def dfs(cost, C, depth=0):
  global min_cost
  if depth == N:
    return
  if (C >= K).all():
    min_cost = min([cost, min_cost])
    return
  dfs(cost+Q[depth][0], C + Q[depth][1:], depth+1)
  dfs(cost, C, depth+1)
  
dfs(0, np.zeros(M))
    
print(min_cost) if min_cost != 10**9 else print(-1)


import numpy as np
import itertools
N, M, K = map(int, input().split())
Q = [np.asarray(input().split(), dtype=int) for i in range(N)]
min_cost = 10**9
def dfs(cost, C, depth=0):
  global min_cost
  if (C >= K).all():
    min_cost = min([cost, min_cost])
    return
  if depth == N:
    return
  dfs(cost+Q[depth][0], C + Q[depth][1:], depth+1)
  dfs(cost, C, depth+1)
  
dfs(0, np.zeros(M))
    
print(min_cost) if min_cost != 10**9 else print(-1)


Verdicts: Wrong Answer

Accepted
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.

Submission attempts (in order):
if __name__ == '__main__':

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

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

    
    INF = 10**19
    ans = INF
    for x in range(2**n):
        ALG = [0]*m
        gokei = 0
        for y in range(n):
            if (x>>y) & 1:
                #print(A[y])
                
                for j in range(m):
                    ALG[j] += A[y][j+1]
                gokei += A[y][0]
        #print("ALG="+str(ALG))
        
        algflg=True
        for k in ALG:
            if k < a:
                algflg=False
                break
        if algflg:
            ans = min(ans,gokei)
    if ans == INF:
        print("-1")
    else:
        print(ans)


if __name__ == '__main__':

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

    A = []
    for i in range(n):
        cmd = list(map(int,input().split()))
        A.append(cmd)
    
    INF = 10**19
    ans = INF
    for x in range(2**n):
        ALG = [0]*m
        gokei = 0
        for y in range(n):
            if (x>>y) & 1:
                
                for j in range(m):
                    ALG[j] += A[y][j+1]
                gokei += A[y][0]
        
        algflg=True
        for k in ALG:
            if k < a:
                algflg=False
                break
        if algflg:
            ans = min(ans,gokei)
    if ans == INF:
        print("-1")
    else:
        print(ans)


Verdicts: Wrong Answer

Accepted
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.

Submission attempts (in order):
n,m,x = map(int,input().split())
li = [list(map(int,input().split())) for i in range(n)]

ans   = 10**30
cost  = 0
score = [0]*m

for i in range(1<<(n+1)):
  for j in range(n):
    if (j>>i)&1:
      for k in range(m):
        score[k] += li[j][k+1]
      cost += li[j][0]
  if min(score)>=x:
    ans = min(ans,cost)
  score = [0]*m
  cost = 0

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

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

ans   = 10**30
cost  = 0
score = [0]*m

for i in range(1<<(n+1)):
  for j in range(n):
    if (j>>i)&1:
      for k in range(m):
        score[k] += li[j][k+1]
      cost += li[j][0]
      print(cost,min(score))
  if min(score)>=x:
    ans = min(ans,cost)
  score = [0]*m
  cost = 0

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

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

ans   = 10**30
cost  = 0
score = [0]*m

for i in range(1<<(n+1)):
  for j in range(n):
    # if (j>>i)&1:
    if i&(1<<j):
      for k in range(m):
        score[k] += li[j][k+1]
      cost += li[j][0]
  if min(score)>=x:
    ans = min(ans,cost)
  score = [0]*m
  cost = 0

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


Verdicts: Wrong Answer

Wrong Answer

Accepted
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.

Submission attempts (in order):
N, M, X = map(int, input().split())

book = [0]*N

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

sorted_book = sorted(book)

A_list = [0]*(M) 
for j in range(1, M+1):
    A_sum = 0
    count = 0

    for i in range(N):
        A_sum += sorted_book[i][j]
        count +=1
        if A_sum >= X:
            break
    
    if A_sum < X:
        A_list[j -1] = -1
    else:
        A_list[j -1] = count


answer = 0
if -1 in A_list:
    answer = -1
else:
    max_A_list = max(A_list)
    for i in range(max_A_list):
        answer += sorted_book[i][0]

print(A_list)
print(answer)


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

book = [0]*N

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

sorted_book = sorted(book)

A_list = [0]*(M) 
for j in range(1, M+1):
    A_sum = 0
    count = 0

    for i in range(N):
        A_sum += sorted_book[i][j]
        count +=1
        if A_sum >= X:
            break
    
    if A_sum < 10:
        A_list[j -1] = -1
    else:
        A_list[j -1] = count


answer = 0
if -1 in A_list:
    answer = -1
else:
    max_A_list = max(A_list)
    for i in range(max_A_list):
        answer += sorted_book[i][0]

print(A_list)
print(answer)



import itertools
import numpy as np

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

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

A = np.array(A)
C = np.array(C)

answer = 10**9
for comb in itertools.product([0, 1], repeat= N):
    cost = 0
    A_memo = np.zeros(M, dtype=int)

    for i in range(N):
        if not comb[i]:
            continue

        A_memo += A[i]
        cost += C[i]

    if (A_memo >= X).sum() == M:
        answer = min(answer, cost)

if answer == 10**9:
    print(-1)
else:
    print(answer)

Verdicts: Wrong Answer

Wrong Answer

Accepted
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.

Submission attempts (in order):
import numpy as np
import sys
from itertools import product

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

ans = 10**9

products = list(product([0,1], repeat=n))

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

min_price = 10**9

for p in products:
    sum_alg = [0]*m
    price = 0
    for i, pp in enumerate(p):
        if pp == 1:
            for j in range(m):
                sum_alg[j] += A[i][j]
            price += c[i]

    if min(sum_alg) > x: 
        min_price = min(price, min_price)


if min_price == 10**9:
    print(-1)
else:
    print(min_price)





import numpy as np
import sys
from itertools import product

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

ans = 10**9

products = list(product([0,1], repeat=n))

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

min_price = 10**9

for p in products:
    sum_alg = [0]*m
    price = 0
    for i, pp in enumerate(p):
        if pp == 1:
            for j in range(m):
                sum_alg[j] += A[i][j]
            price += c[i]

    if min(sum_alg) >= x: 
        min_price = min(price, min_price)


if min_price == 10**9:
    print(-1)
else:
    print(min_price)

Verdicts: Wrong Answer

Accepted