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 itertools
n,m,x=map(int,input().split())
l=list()
for i in range(n):
    l.append(list(map(int,input().split())))
for i in range(1,n+1):
    for j in itertools.combinations(l,i):
        print(j)
        r=[0 for i in range(m)]
        for k in j:
            a=0
            p=0
            for i in range(1,m+1):
                r[i-1]+=k[i]
                a+=r[i-1]>=x
            if a==m:
                for c in j:
                    p+=c[0]
                print(p)
                exit()
print(-1)


import itertools
n,m,x=map(int,input().split())
l=list()
for i in range(n):
    l.append(list(map(int,input().split())))
pp=list()
for i in range(1,n+1):
    for j in itertools.combinations(l,i):
        r=[0 for i in range(m)]
        for k in j:
            a=0
            p=0
            for i in range(1,m+1):
                r[i-1]+=k[i]
                a+=r[i-1]>=x
            if a==m:
                for c in j:
                    p+=c[0]
                pp.append(p)
if len(pp)==0:
    print(-1)
else:
    print(min(pp))


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
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m, x = map(int, readline().split())
c = [list(map(int, readline().split())) for _ in range(n)]

ans = 10 ** 9 + 7
for l in list(itertools.product([0, 1], repeat=n)):
    cart = [0] * (m + 1)
    for i, a in enumerate(l):
        if a == 1:
        array = c[i]
        cart = list(map(lambda x,y: x+y, cart, array))
    if min(cart[1::]) >= x:
        ans = min(ans, cart[0])
print(ans if ans != 10 ** 9 + 7 else '-1')

import itertools
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m, x = map(int, readline().split())
c = [list(map(int, readline().split())) for _ in range(n)]

ans = 10 ** 9 + 7
for l in list(itertools.product([0, 1], repeat=n)):
    cart = [0] * (m + 1)
    for i in [i for i, a in enumerate(l) if a == 1]:
        array = c[i]
        cart = list(map(lambda x,y: x+y, cart, array))
    if min(cart[1::]) >= x:
        ans = min(ans, cart[0])
        
print(ans if ans != 10 ** 9 + 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):
import pandas as pd

import itertools
N, M, X = map(int, input().split())
C = []
A = dict()
for i in range(N):
    CA = list(map(int, input().split()))
    C.append(CA[0])
    for j in range(1, M+1):
        if j in A:
            A[j].append(CA[j])
        else:
            A[j] = [CA[j]]

cost = float("inf")

for i in range(1, N+1):
    for pm in itertools.combinations(list(range(1, N+1)), r=i):
        c = 0
        k = dict()
        for p in pm:
            c += C[p-1]

            for m in range(1, M+1):
                if m in k:
                    k[m] += A[m][p - 1]
                else:
                    k[m] = A[m][p - 1]

        if min(k.values()) >= X:
            cost = min(cost, c)


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

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 itertools import product
def main():
    n, m, x = map(int, input().split())
    books = []
    for _ in range(n):
        books.append(tuple(map(int, input().split())))

    books_set_all = []
    books_pattern = product((0, 1), repeat=n)
    for each_pattern in books_pattern:
        print(each_pattern)
        books_set = [0] * (m + 1)
        for i1 in range(n):
            if each_pattern[i1] == 1:
                for i2 in range(m + 1):
                    books_set[i2] += books[i1][i2]
        books_set_all.append(books_set)
    price_all = []
    for ebs in books_set_all:
        price = ebs[0]
        ebs[0] = x
        if len([j for j in ebs if j >= x]) == m + 1:
            price_all.append(price)
    if len(price_all) > 0:
        print(min(price_all))
    else:
        print(-1)

if __name__ == '__main__':
    main()

from itertools import product
def main():
    n, m, x = map(int, input().split())
    books = []
    for _ in range(n):
        books.append(tuple(map(int, input().split())))

    books_set_all = []
    books_pattern = product((0, 1), repeat=n)
    for each_pattern in books_pattern:
        books_set = [0] * (m + 1)
        for i in each_pattern:
            if i:
                for i2 in range(m + 1):
                    books_set[i2] += books[i][i2]
        books_set_all.append(books_set)
    price_all = []
    for ebs in books_set_all:
        price = ebs[0]
        ebs[0] = x
        if len([j for j in ebs if j >= x]) == m + 1:
            price_all.append(price)
    if len(price_all) > 0:
        print(min(price_all))
    else:
        print(-1)

if __name__ == '__main__':
    main()


import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
import numpy as np
def main():
    n, m, x = map(int, input().split())
    data = np.array(read().split(), np.int64)
    data = data.reshape(n, -1) 
    cost_per_cost = data[:, 0] 
    effect_per_book = data[:, 1:]

    costs = np.zeros(2**n, np.int64)
    
    ability = np.zeros((2**n, m), np.int64)
    for i in range(n):
        costs[1<<i:1<<(i+1)] = costs[:1<<i] + cost_per_cost[i]
        ability[1<<i:1<<(i+1)] = ability[:1<<i] + effect_per_book[i]
    ok = np.all(ability >= x, axis=1)
    res = costs[ok]
    if len(res) == 0:
        print(-1)
    else:
        print(res.min())

if __name__ == '__main__':
    main()



Verdicts: Wrong Answer

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

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M,X = map(int, readline().split())
data = np.array(read().split(), np.int64)
data = data.reshape(N,-1)
C = data[:,0]
A = data[:,1:]

cost = np.zeros(1<<N, np.int64)
dability = np.zeros((1<<N, M), np.int64)

for i in range(N):
  cost[1<<i:1<<(i+1)] = cost[:1<<i] + C[i]
  ability[1<<i:1<<(i+1)] = ability[:1<<i] + A[i]
  
ok = np.all(ability >= X, axis=1)

x = cost[ok]
answer = -1 if len(x) == 0 else x.min()
print(answer)




import sys
import numpy as np
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N,M,X = map(int, readline().split())
data = np.array(read().split(), np.int64)
data = data.reshape(N,-1)
C = data[:,0]
A = data[:,1:]
 
cost = np.zeros(1<<N, np.int64)
ability = np.zeros((1<<N, M), np.int64)
 
for i in range(N):
  cost[1<<i:1<<(i+1)] = cost[:1<<i] + C[i]
  ability[1<<i:1<<(i+1)] = ability[:1<<i] + A[i]
  
ok = np.all(ability >= X, axis=1)
 
x = cost[ok]
answer = -1 if len(x) == 0 else x.min()
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):
from sys import stdin
def main():
    
    readline=stdin.readline
    n,m,x=map(int,readline().split())
    c=[]
    a=[]
    for i in range(n):
        ca=list(map(int,readline().split()))
        c.append(ca[0])
        a.append(ca[1:])

    print(c)
    print(a)
    
    min_res=float("inf")
    for i in range(1<<n):
        output=[]
        res=0
        rikaido=[0]*m
        for j in range(n):
            if(i>>j)&1:
                output.append(j)
        for j in output:
            res+=c[j]
            for k in range(m):
                rikaido[k]+=a[j][k]
        for k in range(m):
            if rikaido[k]<x:
                break
        else:
            min_res=min(res,min_res)

    if min_res==float("inf"):
        min_res=-1

    print(min_res)
if __name__=="__main__":
    main()

from sys import stdin
def main():
    
    readline=stdin.readline
    n,m,x=map(int,readline().split())
    c=[]
    a=[]
    for i in range(n):
        ca=list(map(int,readline().split()))
        c.append(ca[0])
        a.append(ca[1:])
    
    min_res=float("inf")
    for i in range(1<<n):
        output=[]
        res=0
        rikaido=[0]*m
        for j in range(n):
            if(i>>j)&1:
                output.append(j)
        for j in output:
            res+=c[j]
            for k in range(m):
                rikaido[k]+=a[j][k]
        for k in range(m):
            if rikaido[k]<x:
                break
        else:
            min_res=min(res,min_res)

    if min_res==float("inf"):
        min_res=-1

    print(min_res)
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 itertools
import numpy as np

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

lis_C = np.array(list(map(lambda x: x[0], lis_all)))
lis_A = np.array(list(map(lambda x: x[1:], lis_all)))

row_idx = []
bools = [True,False]
for boollis in itertools.product(bools, repeat=M):
    row_idx.append(list(boollis))

c_min = lis_C.sum()+100
for i in range(len(lis_idx)):
    if all(lis_A[row_idx[i]].sum(axis=0) >= X):
        c_min = min(lis_C[row_idx[1]].sum(), c_min)
if c_min > lis_C.sum():
    ans = -1
else :
    ans = c_min
print(ans)

import itertools
import numpy as np

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

lis_C = np.array(list(map(lambda x: x[0], lis_all)))
lis_A = np.array(list(map(lambda x: x[1:], lis_all)))

row_idx = []
bools = [True,False]
for boollis in itertools.product(bools, repeat=N):
    row_idx.append(list(boollis))


c_min = lis_C.sum()+100
for i in range(len(row_idx)):
    if all(lis_A[row_idx[i]].sum(axis=0) >= X):
        c_min = min(lis_C[row_idx[i]].sum(), c_min)
if c_min > lis_C.sum():
    ans = -1
else :
    ans = c_min
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):
print('-1')

import numpy as np
n, m, x = map(int, input().split())
l = []
for i in range(n):
    l += [list(map(int, input().split()))]

a = 1 <<(n )
r = []
for i in range(a):
    li = np.array([0 for _ in range(m +1)])
    for j in range(n):
        if i & (1 << j):
            li += l[j]
#     print(li)
    for k in range(1,m +1):
        if li[k] < x:
            break
        if k == m:
            r +=[li[0]]
        
if len(r) == 0:
    print('-1')
else:
    print(min(r))

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
A,B,C = map(int,input().split())


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

result = []
for n in range(1,len(a)+1):
    for conb in itertools.combinations(a, n):
        result.append(list(conb)) 
print(result)

import numpy as np
import itertools
n,m,x=map(int,input().split())
a=[]
for i in range(n):
    a.append(list(map(int,input().split())))
# a.sort()

result = []

for n in range(1,len(a)+1):
    for conb in itertools.combinations(a, n):
        result.append(np.array(conb)) 

count = 0

ans = []

for i in range(len(result)):
    t = sum(result[i])
    print(t)
    for k in range(1,len(t)):
        print(t[k])
        if t[k] >= x:
            count += 1
        else:
            count = 0
            break
    if count == m:
        ans.append(t[0])
        count = 0
        
    
if len(ans) > 0:
    print(ans)
    
    print(min(ans))
    
else:
    print(-1)


import numpy as np
import itertools
n,m,x=map(int,input().split())
a=[]
for i in range(n):
    a.append(list(map(int,input().split())))
# a.sort()

result = []

for n in range(1,len(a)+1):
    for conb in itertools.combinations(a, n):
        result.append(np.array(conb)) 

count = 0

ans = []

for i in range(len(result)):
    t = sum(result[i])
    # print(t)
    for k in range(1,len(t)):
        # print(t[k])
        if t[k] >= x:
            count += 1
        else:
            count = 0
            break
    if count == m:
        ans.append(t[0])
        count = 0
        
    
if len(ans) > 0:
    # print(ans)
    
    print(min(ans))
    
else:
    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):
n,m,x = map(int, input().split())
c, a = [0]*n, [0]*n
for i in range(n):
    c[i],*a[i] = map(int, input().split())

b = [[a[j][i] for j in range(n)] for i in range(m)]
s = [sum(i) for i in b]
if min(s) < x:
    print(-1)
    exit()
while min(s) >= x:
    mind = c.index(max(c))
    for i in b:
        del i[mind]
    p = c[mind]
    del c[mind]
    s = [sum(i) for i in b]
print(sum(c) + p)


n, m, x = map(int, input().split())
c, a = [0] * n, [0] * n
for i in range(n):
    c[i], *a[i] = map(int, input().split())
l = []
b = [[a[j][i] for j in range(n)] for i in range(m)]
nums = [("0"*n + bin(i)[2:])[-n:] for i in range(1, 2 ** n)]

for i in nums:
    if min(sum(k[j]*int(i[j]) for j in range(len(i))) for k in b) >= x:
        l.append(sum(c[j]*int(i[j]) for j in range(len(i))))
print(min(l) if l 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):
# -*- coding: utf-8 -*-

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

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

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

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

if (count == M):
    money = total

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

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

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

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

ans = 10**8
for s in range(2**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 == 10**8):
    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())
C = [0]*n
A = [[0]*m for i in range(n)]
for i in range(n):
    b = list(map(int,input().split()))
    C[i] = b[0]
    for j in range(1,m+1):
        A[i][j-1] = b[j]
    
MAX = 100000000000
def dfs(a,c,i):
    if min(a)>=x:
        return cost
    elif i == n:
        return MAX
    total_A = [u+v for (u,v) in zip(a,A[i])]
    return min(dfs(a,c,i+1), dfs(total_A,c + C[i], i+1))

ans = dfs([0]*m,0,0)
if ans == MAX:
    print(-1)
else:
    print(ans)

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

maxnum = 10000000000
def dfs(a,cost,i):
    if min(a) >= x:
        return cost
    elif i == n:
        return maxnum
    
    getA = [x+y for (x,y) in zip(a,A[i])]
    
    return min(dfs(a,cost,i+1), dfs(getA,cost+C[i],i+1))

ans = dfs([0]*m,0,0)

if ans == maxnum:
    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

N,M,X = map(int, input().split())
C_A = []
for _ in range(N):
    C_A.append(list(map(int, input().split())))
# print(C_A)

min_price = 10**5 * 12 
rikaido = [0 for _ in range(M)]

for i in itertools.product([0,1], repeat=N):
    price_rikaido = [sum(C_A[j][k]*i[j] for j in range(N)) for k in range(M+1)]
    print(i)
    print(price_rikaido)
    flag = 1
    for l in range(M):
        if price_rikaido[l+1] <X:
            flag = 0
            break
    if flag and (min_price > price_rikaido[0]):
        min_price = price_rikaido[0]
        
if min_price == 10**5 * 12 :
    print(-1)
else:
    print(min_price)


import itertools
 
N,M,X = map(int, input().split())
C_A = []
for _ in range(N):
    C_A.append(list(map(int, input().split())))
# print(C_A)
 
min_price = 10**5 * 12 
rikaido = [0 for _ in range(M)]
possible = 0
for i in itertools.product([0,1], repeat=N):
    price_rikaido = [sum(C_A[j][k]*i[j] for j in range(N)) for k in range(M+1)]
    # print(i)
    
    flag = 1
    for l in range(M):
        if price_rikaido[l+1] <X:
            flag = 0
            break
    if flag and (min_price >= price_rikaido[0]):
        min_price = price_rikaido[0]
        possible = 1
        
if possible:
    print(min_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):
ans = float("inf")
for i in range(1<<n):
    mokuhyo = [0]*m
    cost = 0
    for j in range(n):
        if i>>j&1:
            for r in range(m):
                mokuhyo[r] += c[j][r+1]
            cost += c[j][0]
    for k in mokuhyo:
        if k < x:
            break
        else:
            ans = min(ans, cost)
print("-1" if ans == 10**7 else ans)        

ans = 10**7
for i in range(1<<n):
    mokuhyo = [0]*m
    cost = 0
    for j in range(n):
        if i>>j&1:
            for r in range(m):
                mokuhyo[r] += c[j][r+1]
            cost += c[j][0]
    if all(k>=x for k in mokuhyo):
        ans = min(ans, cost)
print("-1" if ans == 10**7 else ans)        

n,m,x = map(int,input().split())
c = list(list(map(int,input().split())) for _ in range(n))
ans = 10**7
for i in range(1<<n):
    mokuhyo = [0]*m
    cost = 0
    for j in range(n):
        if i>>j&1:
            for r in range(m):
                mokuhyo[r] += c[j][r+1]
            cost += c[j][0]
    if all(k>=x for k in mokuhyo):
        ans = min(ans, cost)
print("-1" if ans == 10**7 else 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):
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]


most_row_price = 10**10
for i in range(2**n):
    comb = str(bin(i)[2:]).zfill(n)
    
    
    money_per_pattern = [0] * n 
    total_money = 0 
    for j in range(n):
        
        
        if comb[j] == '0':
            continue
            
        
        total_money += ca[j][0]
        
        
        for k in range(m):
            understanding[k] += ca[j][k+1]           

    for j in range(m):
        if understanding[j] < x:
            break
    else:
        most_row_price = min(total_money, most_row_price)

if most_row_price == 10**10:
    print(-1)
else:
    print(most_row_price)

import numpy as np
N, M, X = map(int, input().split())
C = []
for _ in range(N):
    C.append(list(map(int, input().split())))
C_np = np.array(C)

for i in np.sum(C_np, axis=0)[1:]:
    if i < X:
        print(-1)
        break

else:
    for i in C_np:
        pass

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


most_row_price = 10**10
for i in range(2**n):
    comb = str(bin(i)[2:]).zfill(n)
    
    
    understanding = [0] * m 
    total_money = 0 
    for j in range(n):
        
        
        if comb[j] == '0':
            continue
            
        
        total_money += ca[j][0]
        
        
        for k in range(m):
            understanding[k] += ca[j][k+1]           

    for j in range(m):
        if understanding[j] < x:
            break
    else:
        most_row_price = min(total_money, most_row_price)

if most_row_price == 10**10:
    print(-1)
else:
    print(most_row_price)

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

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

data = [list(map(int, input().split())) for _ in range(N)]
INF = float('int')

data_all = []
c_min = INF

for i in range(2**N):
    data_tmp = [0]*M
    c = 0
    for j in range(N):
        if((i>>j) & 1):
            for k in range(M):
                data_tmp[k] += data[j][k+1]
            c += data[j][0]
    if(min(data_tmp) >= X):
        c_min = min(c, c_min)

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





import numpy as np

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

data = [list(map(int, input().split())) for _ in range(N)]
INF = float('inf')

data_all = []
c_min = INF

for i in range(2**N):
    data_tmp = [0]*M
    c = 0
    for j in range(N):
        if((i>>j) & 1):
            for k in range(M):
                data_tmp[k] += data[j][k+1]
            c += data[j][0]
    if(min(data_tmp) >= X):
        c_min = min(c, c_min)

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





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):
INF = 10**18

n, m, x = map(int, input().split())
costs = []
a = []
for i in range(n):
    cost, *tmp = map(int, input().split())
    costs.append(cost)
    a.append(tmp)

ans = INF
for i in range(1 << n):
    cost = 0
    ms = [0] * m
    for j in range(n):
        if (i >> j) & 1 == 1:
            cost += costs[j]
            for k in range(m):
                ms[k] += a[j][k]
    can_learn = True
    for j in range(m):
        if ms[j] < x:
            can_learn = False
            break
    if can_learn:
        print(cost, ms)
        ans = min(ans, cost)

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


INF = 10**18

n, m, x = map(int, input().split())
costs = []
a = []
for i in range(n):
    cost, *tmp = map(int, input().split())
    costs.append(cost)
    a.append(tmp)

ans = INF
for i in range(1 << n):
    cost = 0
    ms = [0] * m
    for j in range(n):
        if (i >> j) & 1 == 1:
            cost += costs[j]
            for k in range(m):
                ms[k] += a[j][k]
    can_learn = True
    for j in range(m):
        if ms[j] < x:
            can_learn = False
            break
    if can_learn:
        ans = min(ans, cost)

print(-1 if ans == INF else 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 sys
from itertools import combinations

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

for i in range(N):
    for j in range(1,M+1):
        A[j]+=CA[i][j]

for i in A:
    if i <X:
        print(-1)
        sys.exit()

ans=sum(A)

for i in range(1,N+1):
    for e in combinations(range(N),i):
        c = 0
        A = [0]*(M+1)
        for f in e:
            c += CA[f][0]
            for j in range(M):
                A[i] += CA[f][j+1]
        if min(A) >= X:
            ans = min(ans,c)
else:
    print(ans)


import sys
from itertools import combinations

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

for i in range(N):
    for j in range(1,M+1):
        A[j]+=CA[i][j]

for i in range(1,M+1):
    if A[i] <X:
        print(-1)
        sys.exit()

ans=sum(A)

for i in range(1,N+1):
    for e in combinations(range(N),i):
        c = 0
        A = [0]*(M+1)
        for f in e:
            c += CA[f][0]
            for j in range(M):
                A[i] += CA[f][j+1]
        if min(A) >= X:
            ans = min(ans,c)
else:
    print(ans)


import sys
from itertools import combinations

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

ans=0

for i in range(N):
    ans+=CA[i][0]
    for j in range(1,M+1):
        A[j]+=CA[i][j]


for i in range(1,M+1):
    if A[i] <X:
        print(-1)
        sys.exit()


for i in range(1,N+1):
    for e in combinations(range(N),i):
        c = 0
        A = [0]*M
        for f in e:
            c += CA[f][0]
            for j in range(M):
                A[j] += CA[f][j+1]
        if min(A) >= X:
            ans = min(ans,c)
        
else:
    print(ans)

Verdicts: Wrong Answer

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
from numpy import array


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

a = array(a)

c_min = 1e5 * n
flag = False

for i in range(1, n ** 2 + 1):
    j = str(bin(i))

    b = np.zeros(m+1)

    for k in range(n):
        if j[k] == 1:
            b += a[k]
    
    if np.all(b[1:] >= m):
        c_min = min(c_min, b[0])
        flag = True

if flag == False:
    c_min = -1

print(c_min)



import numpy as np
from numpy import array


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

a = array(a)

c_min = 0
flag = False

for i in range(1, 2 ** n ):
    b = np.zeros(m+1)

    for k in range(n):
        if ((i >> k) & 1):
            b += a[k]
    
    if np.all(b[1:] >= x):
        if flag == False:
            c_min = b[0]
            flag = True
        else:
            c_min = min(c_min, b[0])
        

c_min = int(c_min)

if flag == False:
    c_min = -1

print(c_min)



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 itertools import product
[N, M, X] = [int(i) for i in input().split()]
bk = [[int(i) for i in input().split()] for _ in range(N)]

ans = 12*10**5
for seq in product(range(2), repeat=N):
    S = [0]*(M+1)
    for i in range(N):
       for j in range(M+1):
           S[j] += seq[i]*bk[i][j]
    print(S, seq)       
    if min(S[1:M+1]) >= X:
        ans = min(ans, S[0]) 

print(ans)

from itertools import product
[N, M, X] = [int(i) for i in input().split()]
bk = [[int(i) for i in input().split()] for _ in range(N)]

ans = 12*10**5 + 1
for seq in product(range(2), repeat=N):
    S = [0]*(M+1)
    for i in range(N):
       for j in range(M+1):
           S[j] += seq[i]*bk[i][j]     
    if min(S[1:M+1]) >= X:
        ans = min(ans, S[0])

if ans == 12*10**5 + 1:
    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())
a = []
d = 0
e = False
f = []
z = 0
for i in range(N):
    a.append([])

for i in range(N):
    a[i]= [int(i) for i in input().split()]

for i in range(2 ** N):
    b = np.array([0 for _ in range(M + 1)])
    d = True
    for j in range (N):

        if ((i >> j) & 1):
            b = np.array(a[j]) + b
    print(b)
    z = z + 1
    for k in range(M):
        if b[k + 1] < X:
            d = False
    if d:
        f.append(b[0].tolist())
        e = True
if e:
    print(min(f))
else:
    print("-1")

import numpy as np
N,M,X= map(int,input().split())
a = []
d = 0
e = False
f = []
z = 0
for i in range(N):
    a.append([])

for i in range(N):
    a[i]= [int(i) for i in input().split()]

for i in range(2 ** N):
    b = np.array([0 for _ in range(M + 1)])
    d = True
    for j in range (N):

        if ((i >> j) & 1):
            b = np.array(a[j]) + b
    print(b)
    z = z + 1
    for k in range(M):
        if b[k + 1] < X:
            d = False
    if d:
        f.append(b[0].tolist())
        e = True
if e:
    print(min(f))
else:
    print("-1")

import numpy as np
N,M,X= map(int,input().split())
a = []
d = 0
e = False
f = []
z = 0
for i in range(N):
    a.append([])

for i in range(N):
    a[i]= [int(i) for i in input().split()]

for i in range(2 ** N):
    b = np.array([0 for _ in range(M + 1)])
    d = True
    for j in range (N):

        if ((i >> j) & 1):
            b = np.array(a[j]) + b
    z = z + 1
    for k in range(M):
        if b[k + 1] < X:
            d = False
    if d:
        f.append(b[0].tolist())
        e = True
if e:
    print(min(f))
else:
    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):
N, M, X = map(int, input().split())
C = [0] * N
AA = [list(map(int, input().split())) for i in range(N)]
for i in range(len(AA)):
    C[i] = AA[i][0]
    A[i] = AA[i][1:]
ans = sum(C) + 1
for p in range(2 ** N):
    Y = [0] * M
    cnt = 0
    for i, c in enumerate(C):
        if p % 2 == 1:
            cnt += c
            for j, a in enumerate(A[i]):
                Y[j] += a
        p //= 2
    ans = min(ans, cnt) if min(Y) >= X else ans
print(ans if ans <= sum(C) else -1)

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

for i in range(len(AA)):
    C[i] = AA[i][0]
    A[i] = AA[i][1:]

ans = sum(C) + 1

for p in range(2 ** N):
    Y = [0] * M
    cnt = 0
    for i, c in enumerate(C):
        if p % 2 == 1:
            cnt += c
            for j, a in enumerate(A[i]):
                Y[j] += a
        p //= 2
        
        
    
    ans = min(ans, cnt) if min(Y) >= X else ans
print(ans if ans <= sum(C) 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=map(int,input().split())
A=[0]*(N);C=[0]*(N);c=0;D=[0]*(M);m=10**5;n=0;x=[];z=0;R=[0]*N;f=-1;cost=10**5;p=0
for i in range(N):
  S=list(map(int,input().split()))
  C[i]=S[0]
  A[i]=S[1:len(S)]
#print(C)
#print(A)
for i in range(len(C)):
  x.append(i)

for i, _ in enumerate(x, 1):     
    for j in itertools.permutations(x, r=i):
        for k in x:
          for l in range(M):
            D[l]=D[l]+A[k][l]
        for v in range(M):
          if D[v]<X:
            f=1
        if f!=1:
          for y in x:
            p=p+C[y]
            if p<cost:
              cost=p
          p=0
print(cost if cost!=100000 else -1)

from collections import deque
N,M,X=map(int,input().split())
A=[0]*N;cost=0;C=[0]*N;bit=0;v=[0]*M;f=0;minimum=100000*12+1;e=0
for i in range(N):
  a = deque(list(map(int, input().split())))
  C[i]=a[0]
  a.popleft()
  A[i]=a

#print(A[2][2])
#print(C)

for i in range(2**N):
  for j in range(N):
    bit=(1<<j)
    if (i & bit)>0:
      cost+=C[N-1-j]
      for k in range(M):
        v[k]=v[k]+A[N-1-j][k]
  for l in range(M):
    if v[l]<X:
      f=1
     
  if f!=1 and cost<minimum:
    minimum=cost
    e=i
  cost=0;v=[0]*M;f=0
            
print(minimum if minimum!=100000*12+1 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())
book_list = []

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

print("-1")


N, M, X = map(int, input().split())
book_list = []
cost = [0] * (2 ** N)

cost_parform = []
for i in range(N):
    book_list.append(list(map(int, input().split())))
for i in range(2 ** N):
    bag = []
    rikaido = [0] * M
    for j in range(N):  
        if (i >> j & 1):
            bag.append(j)
    for k in bag:
        # print(bag)
        # print(bag[k])
        cost[i] = cost[i] + book_list[k][0]
        for m in range(M):
            rikaido[m] = rikaido[m] + book_list[k][m+1]

    count = 0
    for m in range(M):
        if rikaido[m] >= X:
            count += 1
    if count == M:
        cost_parform.append(cost[i])

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

#print(cost_parform)

Verdicts: Wrong Answer

Accepted