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




INF = 1000000000000000000000000000
ans = INF

for i in range(1<<n):  #n bits all searches
    # 1<<n == 2**n
    c = 0
    sums = [0]*m
    for j in range(n):
        if i>>j & 1: #i>>j %2 == 1  is also fine.
            #apply this candidate. 
            c += costs[j][0]
            for k in range(m):
                sums[k] += costs[j][k+1]
    
'''
    cost = 0
    c = 0
    sums = [0] * m
    use_index=[]
    for j in range(n):
        if i%2==1:
            use_index.append(j)
        i >>= 1
    
    for v in use_index:
        c += costs[v][0]        
        for j in range(m):
            sums[j] += costs[v][j+1]
'''

    if min(sums) >= x:
        ans = min(ans, c)

'''            
    judge=True
    for j in range(m):
        if sums[j]<x:
            judge=False
            break
    
    if judge:
        ans = min(ans, c)
'''
ans = -1 if ans==INF 
print(ans)



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




INF = 1000000000000000000000000000
ans = INF

for i in range(1<<n):  #n bits all searches
    # 1<<n == 2**n
    c = 0
    sums = [0]*m
    for j in range(n):
        if i>>j & 1: #i>>j %2 == 1  is also fine.
            #apply this candidate. 
            c += costs[j][0]
            for k in range(m):
                sums[k] += costs[j][k+1]    
    '''
    cost = 0
    c = 0
    sums = [0] * m
    use_index=[]
    for j in range(n):
        if i%2==1:
            use_index.append(j)
        i >>= 1
    
    for v in use_index:
        c += costs[v][0]        
        for j in range(m):
            sums[j] += costs[v][j+1]
    '''
    
    #if min(sums) >= x:
    if all(s>=x for x in sums):
        ans = min(ans, c)
'''            
    judge=True
    for j in range(m):
        if sums[j]<x:
            judge=False
            break
    
    if judge:
        ans = min(ans, c)
'''
if ans==INF:
    print(-1)
else:
    print(ans)
 


#abc_167_c


from itertools import product

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

INF = 1000000000000000000000000000
ans = INF


lists = list(product(list(range(2)), repeat = n))
for v in lists:
'''
for i in range(1<<n):  #n bits all searches
    # 1<<n == 2**n
'''
    c = 0
    sums = [0]*m
    for j in range(n):
        if v[j]==1:        
        '''
        if i>>j & 1: #i>>j %2 == 1  is also fine.
        '''
            #apply this candidate. 
            c += costs[j][0]
            for k in range(m):
                sums[k] += costs[j][k+1]    
                
                
    if min(sums) >= x: 
        ans = min(ans, c)                
    
    
        
if ans==INF:
    print(-1)
else:
    print(ans)

#abc_167_c


from itertools import product

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

INF = 1000000000000000000000000000
ans = INF


lists = list(product(list(range(2)), repeat = n))
for v in lists:
    '''
    for i in range(1<<n):  #n bits all searches
        # 1<<n == 2**n
    '''
    c = 0
    sums = [0]*m
    for j in range(n):
        if v[j]==1:        
            '''
            if i>>j & 1: #i>>j %2 == 1  is also fine.
            '''
            #apply this candidate. 
            c += costs[j][0]
            for k in range(m):
                sums[k] += costs[j][k+1]    
                
                
    if min(sums) >= x: 
        ans = min(ans, c)                
    
    
        
if ans==INF:
    print(-1)
else:
    print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted