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):
import numpy as np

N, M, X = map(int, input().split())
C = np.zeros(N)
A = np.zeros((N, M))


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

C_MIN = -1
for i in range(2 ** N):
    C_SUM = 0
    A_SUM = np.zeros(M)
    for j in range(N):
        if ((i >> j) & 1):
            C_SUM += C[j]
            A_SUM += A[j]
    if np.all(A_SUM >= X):
        if C_SUM < C_MIN and not C_MIN == -1:
            C_MIN = C_SUM
            
if C_MIN == -1:
    print("-1")
else:
    print(int(C_MIN))

import numpy as np

N, M, X = map(int, input().split())
C = np.zeros(N)
A = np.zeros((N, M))


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

C_MIN = -1
for i in range(2 ** N):
    C_SUM = 0
    A_SUM = np.zeros(M)
    for j in range(N):
        if ((i >> j) & 1):
            C_SUM += C[j]
            A_SUM += A[j]
    if np.all(A_SUM >= X):
        if C_SUM < C_MIN and not C_MIN == -1:
            C_MIN = C_SUM
            
if C_MIN == -1:
    print("-1")
else:
    print(int(C_MIN))

import numpy as np

N, M, X = map(int, input().split())
C = np.zeros(N)
A = np.zeros((N, M))


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

C_MIN = -1
for i in range(2 ** N):
    C_SUM = 0
    A_SUM = np.zeros(M)
    for j in range(N):
        if ((i >> j) & 1):
            C_SUM += C[j]
            A_SUM += A[j]
    if np.all(A_SUM >= X):
        if C_SUM < C_MIN or C_MIN == -1:
            C_MIN = C_SUM
            
if C_MIN == -1:
    print("-1")
else:
    print(int(C_MIN))

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())

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

count = 0
for i in range(M):
    if X <= sum(A[i]):
        count += 1

ans = [sum(A[i]) for i in range(M)]
ans_flag = [False for _ in range(M)]
cost = sum(C)
if count != M:
    print('-1')
else:
    for _ in range(M):
        idx = C.index(max(C))
        baf = C[idx]
        for i in range(M):
            ans[i] -= A[i][idx]
            if ans[i] < X:
                ans_flag[i] = True
            del A[i][idx]
        
        cost -= C[idx]
        del C[idx]

        if (sum(ans_flag) > 0):
            break

    print(cost+baf)

N, M, X = map(int, input().split())
cost = []
A = []
for _ in range(N):
    ca = list(map(int, input().split()))
    cost.append(ca[0])
    A.append(ca[1:])

ans = 10**9
for bit in range(2**N):
    alg = [0]*M
    c = 0
    for i in range(N):
        if bit >> i & 1 == 1:
            for j in range(M):
                alg[j] += A[i][j]
            c += cost[i]
    if min(alg) >= X:
        ans = min(ans, c)

if ans == 10**9:
    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())
l=[]
for i in range (N):
  l.append(list(map(int,input().split())))
ans=10000000
for i in range(2**N):
  score=[0]*M
  coin=0
  for j in range(N):
    if i>=2**(N-1-j):
      for p in range(M):
        score[p]+=l[j][p+1]
      coin+=l[j][0]
      i-=2**(N-1-j)
  flag=0
  for q in range(M):
    if score[q]<X:
      flag=1
  if flag==0:
    if ans>coin:
      ans=coin
if ans=10000000:
  print("-1")
else:
  print(ans)

N,M,X=map(int,input().split())
l=[]
for i in range (N):
  l.append(list(map(int,input().split())))
ans=0
for i in range(2**N):
  score=[0]*M
  coin=0
  for j in range(N):
    if i>=2**(N-1-j):
      for p in range(M):
        score[p]+=l[j][p+1]
        coin+=l[j][0]
      i-=2**(N-1-j)
  flag=0
  for q in range(M):
    if score(q)<X:
      flag=1
  if flag==0:
    if ans<coin:
      ans=coin
print(coin)

N,M,X=map(int,input().split())
l=[]
for i in range (N):
  l.append(list(map(int,input().split())))
ans=10000000
for i in range(2**N):
  score=[0]*M
  coin=0
  for j in range(N):
    if i>=2**(N-1-j):
      for p in range(M):
        score[p]+=l[j][p+1]
      coin+=l[j][0]
      i-=2**(N-1-j)
  flag=0
  for q in range(M):
    if score[q]<X:
      flag=1
  if flag==0:
    if ans>coin:
      ans=coin
if ans==10000000:
  print("-1")
else:
  print(ans)

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):
# coding:utf-8
n, m, x = map(int, input().split())

book = [list(map(int, input().split())) for _ in range(n)]
all_book = [0] * 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)

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]


# coding:utf-8

n, m, x = map(int, input().split())
book = [list(map(int, input().split())) for _ in range(n)]
ans = 12 * (10 ** 5) + 1

for bit in range(2 ** n):
    tmp_book = [0] * m
    price = 0
    for i in range(n):
        if ((bit >> i) & 1):
            price += book[i][0]
            for j in range(m):
                tmp_book[j] += book[i][j + 1]
    if all(item >= x for item in tmp_book):
        ans = min(price, ans)

if ans != 12 * (10 ** 5) + 1:
    print(ans)
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 sys
sys.setrecursionlimit(10000000)
INF = 10 ** 10
ans = INF


def rec(A, C, X, idx, ability, sum_):
    if idx == len(A):
        for i in range(len(ability)):
            if ability[i] < X:
                break
        else:
            global ans
            ans = min(sum_, ans)
    else:
        # not buy
        rec(A, C, X, idx+1, ability, sum_)
        M = len(A[0])
        import copy 
        for i in range(M):
            ability[i] += A[idx][i]
        rec(A, C, X, idx+1, copy.copy(ability), sum_+C[idx])


def main():
    N, M, X = map(int, input().split())
    C = []
    A = []
    for i in range(N):
        lists = [int(c) for c in input().split()]
        ci = lists[0]
        ai = lists[1:]
        C.append(ci)
        A.append(ai)

    ability = [0] * M
    rec(A, C, X, 0, ability, 0)

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

    
    



if __name__ == '__main__':
    main()


import sys
sys.setrecursionlimit(10000000)
import numpy as np



def main():
    N, M, X = map(int, input().split())
    C = []
    A = []
    INF = 10 ** 10
    ans = INF
    for i in range(N):
        lists = [int(c) for c in input().split()]
        ci = lists[0]
        ai = lists[1:]
        C.append(ci)
        A.append(ai)


    for i in range(1 << N):
        ability = np.zeros((M, ))
        cost = 0
        for j in range(N):
            if (i >> j) & 1:
                ability += np.array(A[j])
                cost += C[j]
        if sum(ability >= X) == M:
            ans = min(ans, cost)

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

    
    



if __name__ == '__main__':
    main()


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 = list(map(int, input().split()))
Arr = np.zeros((N,M+1))
List = np.zeros(M)
 
for i in range(N):
    Arr[i] = list(map(int, input().split()))
    
for j in range(M):
    List[j] = np.sum(Arr[:,j])

if np.any(List<10):
    print(-1)

else:
    List = sorted(List)
    for i in range(N+1):
        for team in itertools.combinations(List,i):
            Sum = np.sum(Arr[team,:])
            if np.all(Sum>=10):
                break

import numpy as np
import itertools

N, M, X = list(map(int, input().split()))
Arr = np.zeros((N,M+1))
List = np.zeros(M)

for i in range(N):
  Arr[i] = list(map(int, input().split()))
  
for j in range(M):
  List[j] = np.sum(Arr[:,j])

if np.any(List<10):
  print(-1)
  
else:
  List = sorted(List)
  for i in range(N+1):
    for team in itertools.combinations(List,i):
      Sum = np.sum(Arr[team,:])
      if np.all(Sum>=10):
        break
    
  


N,M,X = map(int,input().split())
B = [list(map(int,input().split())) for i in range(N)]
ANS = 10**5 * 12 + 1
for i in range(1<<N):
    SCORE=[0]*M
    MONEY=0
    for j in range(N):
        if (1<<j) & i != 0:
            MONEY+=B[j][0]
            for k in range(M):
                SCORE[k]+=B[j][k+1]
    if min(SCORE)>=X:
        ANS=min(ANS,MONEY)
if ANS == 10**5 * 12 + 1:
    print(-1)
else:
    print(ANS)


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):
import itertools
 
N, M, X = map(int, input().split())
l = []
for _ in range(N):
  l.append(list(map(int, input().split())))

b = [i for i in range(N)]
n = len(b)

b_pairs = []
for i in range(1, n+1):
    b_pairs += list(itertools.combinations(b, i))

cnt = 0
A = [0] * M
B = []
C = []
for i in range(2 ** N - 1):
  w = len(b_pairs[i])
  for j in range(M):
    for k in range(w):
      A[j] += l[b_pairs[i][k]][j + 1]
  B.append(A)
  A = [0] * M
  
for i in range(2 ** N - 1):
  w = len(b_pairs[i])
  for k in range(w):
    cnt += l[b_pairs[i][k]][0]
  C.append(cnt)
  cnt = 0

for i in range(len(B)):
  for j in range(M):
    if B[i][j] >= X:
      pass
    else:
      B[i] = 0
      break

for i in range(len(B)):
  if B[i] != 0:
    break
  else:
    print(-1)

for i in range(len(B)):
  if B[i] != 0:
    B[i] = C[i]
  else:
    B[i] = 1000000000000

print(min(B))

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

b = [i for i in range(N)]
n = len(b)

b_pairs = []
for i in range(1, n+1):
    b_pairs += list(itertools.combinations(b, i))

cnt = 0
A = [0] * M
B = []
C = []
for i in range(2 ** N - 1):
  w = len(b_pairs[i])
  for j in range(M):
    for k in range(w):
      A[j] += l[b_pairs[i][k]][j + 1]
  B.append(A)
  A = [0] * M
  
for i in range(2 ** N - 1):
  w = len(b_pairs[i])
  for k in range(w):
    cnt += l[b_pairs[i][k]][0]
  C.append(cnt)
  cnt = 0

for i in range(len(B)):
  for j in range(M):
    if B[i][j] >= X:
      pass
    else:
      B[i] = 0
      break
if B == [0] * len(B):
  print(-1)
  exit()

for i in range(len(B)):
  if B[i] != 0:
    B[i] = C[i]
  else:
    B[i] = 1000000000000

print(min(B))

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 copy import deepcopy

N, M, X = [int(i) for i in input().split()]

CAS = [[int(i) for i in input().split()] for _ in range(N)]


ok = False
mi = [float('inf'), *[0]*(M-1)]

fs = '{:0' + str(N-1) + 'b}'

for i in range(2**N):
  s = fs.format(i)
  t = [0]*M
  for i, f in enumerate(s):
    if f == '1':
      t = [a+b for a, b in zip(CAS[i], t)]

  if all(a >= X for a in t[1:]) and mi[0] > t[0]:
    mi = t
    ok = True


if ok:
  print(mi[0])
else:
  print(-1)


from copy import deepcopy

N, M, X = [int(i) for i in input().split()]

CAS = [[int(i) for i in input().split()] for _ in range(N)]


ok = False
mi = [float('inf'), *[0]*(M)]

for i in range(2**N):
  t = [0]*(M+1)
  for j in range(N):
    if (i >> j) & 1:
      t = [a+b for a, b in zip(CAS[j], t)]

  if all(a >= X for a in t[1:]) and mi[0] > t[0]:
    mi = t
    ok = True


if ok:
  print(mi[0])
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):
n,m,x=map(int,input().split())
c=[list(map(int,input().split())) for _ in range(n)]
result=-1
for i in range(2**n):
  t=[0]*m
  money=0
  for j in range(n):
    if (i>>j)&1==0:
      continue
    money+=c[j][0]
    for k in range(1,m):
      t[k]+=c[j][k]
  if all(xx>=x for xx in t):
    if result==-1:
      result=money
    else:
      result=min(result,money)
print(result)

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

for i in range(2**n):
  money=0
  tm=[0]*m
  for j in range(n):
    if (i>>j)&1==0:
      continue
    money+=c[j]
    for k in range(m):
      tm[k]+=a[j][k]
    if all(xx>=x for xx in tm):
      if result==-1:
        result=money
      else:
        result=min(money,result)
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())
A = np.array([[int(i) for i in input().split()] for _ in range(N)])
total = np.sum(A,axis=0)
flag = True if all((a>=X  for a in total[1:])) else False
ans = total[0]

if flag:
    for i in range(1,N+1):
        for v in itertools.combinations([i for i in range(N)], i):
            B = np.array([A[j] for j in v])
            total2 = np.sum(B, axis=0)
            sabun = total-total2
            if all(a>=X for a in sabun[1:]):
                ans = min(ans, sabun[0])
print(ans if flag else -1)

import numpy as np
import itertools

def check():
    N,M,X = map(int, input().split())
    A = np.array([[int(i) for i in input().split()] for _ in range(N)])
    total = np.sum(A,axis=0)
    flag = True if all((a>=X  for a in total[1:])) else False
    ans = total[0]

    if flag:
        for i in range(1,N+1):
            for v in itertools.combinations([i for i in range(N)], i):
                B = np.array([A[j] for j in v])
                total2 = np.sum(B, axis=0)
                sabun = total-total2
                if all(a>=X for a in sabun[1:]):
                    ans = min(ans, sabun[0])
    print(ans if flag else -1)
    
check()

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 itertools
import sys
import numpy as np

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

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


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


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


import itertools
import sys
import numpy as np

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

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


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


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


import itertools
import sys
import numpy as np

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

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


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


min_value = sys.maxsize
result.sort()
for r in result:
    if ex(r):
        print(r[0])
        exit()

print(-1)


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
N,M,X=map(int,input().split())
allList=[]
for _ in range(N):
    allList.append(np.array(list(map(int,input().split()))))
minnum=10**7
for i in range(2**N):
    skill=[0]*(M+1)
    flag=True
    for row in range(N):
        if i&(2**row)>0:
            skill+=allList[row]
    for i in range(M):
        if skill[j+1]<X:
            flag=False
    if flag:
        minnum=min(minnum,skill[0])
if minnum==10**7:
    minnum=-1
print(minnum)

import numpy as np
N,M,X=map(int,input().split())
allList=[]
for _ in range(N):
    allList.append(np.array(list(map(int,input().split()))))
minnum=10**7
for i in range(2**N):
    skill=[0]*(M+1)
    flag=True
    for row in range(N):
        if i&(2**row)>0:
            skill+=allList[row]
    for j in range(M):
        if skill[j+1]<X:
            flag=False
    if flag:
        minnum=min(minnum,skill[0])
if minnum==10**7:
    minnum=-1
print(minnum)

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 sys
from itertools import product
import numpy as np
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N, M, X = map(int, readline().split())
    CA = list(list(map(int, readline().split())) for _ in range(N))
    CA = np.array(CA)
    target = [0] + [X]*M
    target = np.array(target)
    ans = INF
    for i in range(2**N):
        print(i)
        tmp = 0
        for j in range(N):
            if (i>>j)&1:
               tmp += CA[j]
        if np.all(tmp>=target):
            ans = min(ans, tmp[0])
    print(-1 if ans==INF else ans)

if __name__ == '__main__':
    main()

import sys
from itertools import product
import numpy as np
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N, M, X = map(int, readline().split())
    CA = list(list(map(int, readline().split())) for _ in range(N))
    CA = np.array(CA)
    target = [0] + [X]*M
    target = np.array(target)
    ans = INF
    for i in range(2**N):
        tmp = 0
        for j in range(N):
            if (i>>j)&1:
               tmp += CA[j]
        if np.all(tmp>=target):
            ans = min(ans, tmp[0])
    print(-1 if ans==INF else ans)

if __name__ == '__main__':
    main()

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):
nmx = input('')
n = int(nmx.split(' ')[0])
m = int(nmx.split(' ')[1])
x = int(nmx.split(' ')[2])

clist=[]
alist=[]
for i in range(n):
    ca = input('')
    c = ca.split(' ')[0]
    clist.append(c)
    a = []
    for j in range(1,m+1):
        a.append(ca.split(' ')[j])
    alist.append(a)

min_price=99999999999
for i in range(2**n):
    skilllist=[0]*m
    buylist = [0]*n
    cost=0
    for j in range(n):
        if (i>>j )&1:
            buylist[j]=1
            cost+=int(clist[j])
            a = alist[j]
            for k in range(m):
                skilllist[k]+=int(a[k])

    ok = True
    for skill in skilllist:
        if skill < x:
            ok = False
    if ok and cost < min_price:
        min_price=cost
    print('{}:\\{} :{} ->{} [{}]'.format(i,cost,buylist,skilllist,min_price))
if min_price == 99999999999:
    min_price=-1
print(min_price)



nmx = input('')
n = int(nmx.split(' ')[0])
m = int(nmx.split(' ')[1])
x = int(nmx.split(' ')[2])

clist=[]
alist=[]
for i in range(n):
    ca = input('')
    c = ca.split(' ')[0]
    clist.append(c)
    a = []
    for j in range(1,m+1):
        a.append(ca.split(' ')[j])
    alist.append(a)

min_price=99999999999
for i in range(2**n):
    skilllist=[0]*m
    buylist = [0]*n
    cost=0
    for j in range(n):
        if (i>>j )&1:
            buylist[j]=1
            cost+=int(clist[j])
            a = alist[j]
            for k in range(m):
                skilllist[k]+=int(a[k])

    ok = True
    for skill in skilllist:
        if skill < x:
            ok = False
    if ok and cost < min_price:
        min_price=cost

if min_price == 99999999999:
    min_price=-1
print(min_price)



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):
nmx=list(map(int, input().split()))
N=nmx[0]
M=nmx[1]
X=nmx[2]
mylist=[]
for i in range(N):
    mylist.append(list(map(int, input().split())))
Ans=10000*12+1
for i in range(2**N):
    A=[[0]*M]
    C=0
    for j in range(N):
        if (i>>j) & 1:
            C+=mylist[j][0]
            for k in range(M):
                A[k]=A[k]+mylist[j][k+1]
    if min(A)>=X:
        #Ans=min(Ans, C)
if Ans==10000*12+1:
    print(-1)
else:
    print(Ans)



nmx=list(map(int, input().split()))
N=nmx[0]
M=nmx[1]
X=nmx[2]
mylist=[]
for i in range(N):
    mylist.append(list(map(int, input().split())))
Ans=100000*12+1
for i in range(2**N):
    A=[0]*M
    C=0
    for j in range(N):
        if (i>>j) & 1:
            C+=mylist[j][0]
            for k in range(M):
                A[k]+=mylist[j][k+1]
    if min(A)>=X:
        Ans=min(Ans, C)
if Ans==100000*12+1:
    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 itertools
min_price = 10**9
for k in range(n):
    for comb in itertools.combinations(range(m), k+1):
        sums = [0] * m
        price = 0
        for c in comb:
            price += C[c]
            for i in range(m):
                sums[i] += A[c][i]

#         print(comb)
#         print(sums)
        if sum([y >= x for y in sums]) == len(A):
            min_price = min(min_price, price)

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

import itertools

n,m,x = map(int,input().split())
C, A = [], []
for i in range(n):
    ca = list(map(int, input().split()))
    C.append(ca[0])
    A.append(ca[1:])

min_price = 10**9
for k in range(n):
    for comb in itertools.combinations(range(n), k+1):
        sums = [0] * m
        price = 0
        for c in comb:
            price += C[c]
            for i in range(m):
                sums[i] += A[c][i]

#         print(comb)
#         print(sums)
#         print(min_price)
        if sum([y >= x for y in sums]) == m:
            min_price = min(min_price, price)

if min_price == 10**9:
    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):
import sys

n, m, x =map(int,input().split())
g = []
for _ in range (n):
     array = list(map(int,input().split()))
     g.append(array)
print(g)


n, m, x =map(int,input().split())
s = [list(map(int, input().split())) for _ in range(n)]
ans = 10000000
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 == 10000000:
  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):
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def min_needed_value(values, skills, X):
    cand = []
    for i in range(2**len(values)):
        get_skill = [0] * len(skills[0])
        get_value = 0
        for j in range(len(values)):
            if (i >> j) & 1:
                get_skill = [x + y for (x, y) in zip(get_skill, skills[j])]
                get_value += values[j]
        if all([s > X for s in get_skill]): cand.append(get_value)
    sorted(cand)
    if len(cand) == 0: return -1
    else: return cand[0]


def main():
    N, M, X = map(int, input().split())
    values = []
    skills = []
    for _ in range(N):
        Book = list(map(int, input().split()))
        values.append(Book[0])
        skills.append(Book[1:])
    print(min_needed_value(values, skills, X))

if __name__ == "__main__":
    main()


#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def min_needed_value(values, skills, X):
    import sys
    ans = sys.maxsize
    for i in range(2**len(values)):
        get_skill = [0] * len(skills[0])
        get_value = 0
        for j in range(len(values)):
            if (i >> j) & 1:
                get_skill = [x + y for (x, y) in zip(get_skill, skills[j])]
                get_value += values[j]
        
        if all([s >= X for s in get_skill]): ans = min(ans, get_value)
    if ans == sys.maxsize: return -1
    else: return ans

def main():
    N, M, X = map(int, input().split())
    values = []
    skills = []
    for _ in range(N):
        Book = list(map(int, input().split()))
        values.append(Book[0])
        skills.append(Book[1:])
    print(min_needed_value(values, skills, X))

if __name__ == "__main__":
    main()


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 = [list(map(int,input().split())) 
          for nesya in range(n)]
arugo = [0]*m
hoge = 0
while c in c_list:
  arugo[0] += c[1]
  arugo[1] += c[2]
  arugo[2] += c[3]
  hoge += c[0]
if arugo[0] < 10 or arugo[1] < 10 or arugo[2] < 10:
  print(-1)
else:
  print(hoge)

n,m,x = map(int,input().split())
c_list = [list(map(int,input().split())) 
          for nesya in range(n)]
arugo = [0]*m
hoge = 0
for c in c_list:
  arugo[0] += c[1]
  arugo[1] += c[2]
  arugo[2] += c[3]
  hoge += c[0]
if arugo[0] < 10 or arugo[1] < 10 or arugo[2] < 10:
  print(-1)
else:
  print(hoge)

def bit_set(num:int,n:int):
  if num & (1<<n):
    return True
  return False

n,m,x = map(int,input().split())
ca_list = [list(map(int,input().split())) 
           for nesya in range(n)]
c = -1
for i in range(2**n):
  skill = [0]*m
  cost = 0
  for k in range(n):
    if bit_set(i,k) == True:
      ca =  ca_list[k]
      cost += ca[0]
      a = ca[1:]
      skill = [j+l for (j,l) in zip(skill, a)]
  if all((hoge >= x) for hoge in skill):
    if c == -1:
      c = cost
    else:
      c = min(c,cost)
print(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):
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:
        print(s)
        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)

N,M,X=map(int,input().split())
A=[list(map(int,input().split())) for _ in range (N)]
ans=10**20

for bit in range(2**N):
    C=[0]*M
    cost=0
    for i in range(N):
        if (bit>>i)&1==1:
            cost+=A[i][0]
            for j in range(1,M+1):
                C[j-1]+=A[i][j]
    if min(C)>=X:
        ans=min(ans,cost)
print(ans if ans!=10**20 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):
C = []
A = []
for _ in range(N):
    l = list(map(int,input().split()))
    C.append(l[0])
    A.append(np.array(l[1:]))
ans = 10**100
for i in range(2**N):
    rikaido = np.zeros(M)
    c = 0
    for j in range(N):
        if (i >> j) & 1:
            c += C[j]
            rikaido += A[j]
    if all([x >= X for x in rikaido]):
        ans = min(ans, c)
print(ans if ans != 10**100 else -1)

import numpy as np
N,M,X = map(int,input().split())
C = []
A = []
for _ in range(N):
    l = list(map(int,input().split()))
    C.append(l[0])
    A.append(np.array(l[1:]))
ans = 10**100
for i in range(2**N):
    rikaido = np.zeros(M)
    c = 0
    for j in range(N):
        if (i >> j) & 1:
            c += C[j]
            rikaido += A[j]
    if all([x >= X for x in rikaido]):
        ans = min(ans, c)
print(ans if ans != 10**100 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):
import itertools

n, m, x = list(map(int, input().split()))
all_list = []
for i in range(n):
    tmp = list(map(int, input().split()))
    all_list.append(tmp)

ok = False
cur_price = (10 ** 5) * n + 1
for i in range(1, n + 1):
    answers = list(itertools.combinations(range(n), i))
    # print(answers)
    for ans_list in answers:
        sum_list = [0] * (m + 1)
        print(sum_list)
        for ans in ans_list:
            # print(all_list[int(ans[0])])
            sum_list = [a + b for a, b in zip(sum_list, all_list[int(ans)])]
        # print(sum_list)
        if min(sum_list[1:]) >= x:
            if sum_list[0] < cur_price:
                cur_price = sum_list[0]
                ok = True

if ok:
    print(cur_price)
else:
    print(-1)


import itertools

n, m, x = list(map(int, input().split()))
all_list = []
for i in range(n):
    tmp = list(map(int, input().split()))
    all_list.append(tmp)

ok = False
cur_price = (10 ** 5) * n + 1
for i in range(1, n + 1):
    answers = list(itertools.combinations(range(n), i))
    # print(answers)
    for ans_list in answers:
        sum_list = [0] * (m + 1)
        # print(sum_list)
        for ans in ans_list:
            # print(all_list[int(ans[0])])
            sum_list = [a + b for a, b in zip(sum_list, all_list[int(ans)])]
        # print(sum_list)
        if min(sum_list[1:]) >= x:
            if sum_list[0] < cur_price:
                cur_price = sum_list[0]
                ok = True

if ok:
    print(cur_price)
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 = map(int,input().split())
A = [list(map(int,input().split())) for i in range(N)]

z = [i for i in range(1, N)]
m = [1000000000000000000]

for i in range(N):
    x = list(itertools.combinations(z,i+1))

    for s in x:
        for k in range(1,M+1):
            C = sum(A[j-1][k] for j in s)
            if C < X:
                break
        else:
            m.append(sum(A[o-1][0] for o in s))
print(min(m) if min(m)!=1000000000000000000 else -1)

import itertools
N,M,X = map(int,input().split())
A = [list(map(int,input().split())) for i in range(N)]

z = [i for i in range(1, N)]
m = [1000000000000000000]

for i in range(N):
    x = list(itertools.combinations(z,i+1))
    print(x)
    for s in x:
        for k in range(1,M+1):
            C = sum(A[j-1][k] for j in s)
            if C < X:
                break
        else:
            m.append(sum(A[o-1][0] for o in s))
print(m)
print(min(m) if min(m)!=1000000000000000000 else -1)

import itertools
N,M,X = map(int,input().split())
A = [list(map(int,input().split())) for i in range(N)]

z = [i for i in range(1, N+1)]
m = [1000000000000000000]

for i in range(N):
    x = list(itertools.combinations(z,i+1))

    for s in x:

        for k in range(1,M+1):
            C = sum(A[j-1][k] for j in s)
            if C < X:
                break
        else:
            m.append(sum(A[o-1][0] for o in s))

print(min(m) if min(m)!=1000000000000000000 else -1)


Verdicts: Wrong Answer

Wrong Answer

Accepted