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

ALL = np.zeros((1, M+1))
for n in range(N):
  CA = np.array([ int(i) for i in input().split() ])
  ALL = np.vstack([ALL, CA])

A  = ALL.sum(axis=0)
cost =12*10**5+1
#ALL = np.sort(ALL, axis=0)

for n in range(2**N):
    a = str(bin(n))[2:]
    b = N-len(a)
    c = np.array(list('0'*b+a)).astype('bool')
    #print(c)
    ALL2 = ALL[1:]
    check = ALL2[c].sum(axis=0)
   
    if (check[1:] < X).sum() < 1:
      if  cost >  check[0]:
        cost = check[0]


if cost == 2**100:
  cost = -1
print(cost) 

import numpy as np

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

ALL = np.zeros((1, M+1))
for n in range(N):
  CA = np.array([ int(i) for i in input().split() ])
  ALL = np.vstack([ALL, CA])

A  = ALL.sum(axis=0)
cost =2**100
#ALL = np.sort(ALL, axis=0)

for n in range(2**N):
    a = str(bin(n))[2:]
    b = N-len(a)
    c = np.array(list('0'*b+a)).astype('bool')
    #print(c)
    ALL2 = ALL[1:]
    check = ALL2[c].sum(axis=0)
   
    if (check[1:] < X).sum() < 1:
      if  cost >  check[0]:
        cost = check[0]


if cost == 2**100:
  cost = -1
print(cost) 

import numpy as np

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

ALL = np.zeros((1, M+1))
for n in range(N):
  CA = np.array([ int(i) for i in input().split() ])
  ALL = np.vstack([ALL, CA])

A  = ALL.sum(axis=0)
cost =99999999999999
#ALL = np.sort(ALL, axis=0)


if (A[1:] < X).sum() > 0:
  print(-1)
else:
  for n in range(2**N):
    a = str(bin(n))[2:]
    b = N-len(a)
    c = np.array(list('0'*b+a)).astype('bool')
    #print(c)
    ALL2 = ALL[1:]
    check = ALL2[c].sum(axis=0)

    #print(check[0])
    # print(check[1:])
    if (check[1:] < X).sum() == 0:
      if  cost >=  check[0]:
        cost = check[0]

  print(cost)

import numpy as np

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

ALL = np.zeros((1, M+1))
for n in range(N):
  CA = np.array([ int(i) for i in input().split() ])
  ALL = np.vstack([ALL, CA])

A  = ALL.sum(axis=0)
cost =2**100
#ALL = np.sort(ALL, axis=0)


if (A[1:] < X).sum() > 0:
  print(-1)
else:
  for n in range(2**N):
    a = str(bin(n))[2:]
    b = N-len(a)
    c = np.array(list('0'*b+a)).astype('bool')
    #print(c)
    ALL2 = ALL[1:]
    check = ALL2[c].sum(axis=0)
   
    if (check[1:] < X).sum() == 0:
      if  cost >  check[0]:
        cost = check[0]

  print(cost) 

import numpy as np

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

ALL = np.zeros((1, M+1))
for n in range(N):
  ALL = np.vstack([
    			  ALL, 
                  np.array([ int(i) for i in input().split() ])
                  ])

cost =12*10**5+1
for n in range(2**N):
    a = str(bin(n))[2:]
    b = N-len(a)
    c = np.array(list('0'*b+a)).astype('bool')
    #print(c)
    ALL2 = ALL[1:]
    check = ALL2[c].sum(axis=0)
   
    if (check[1:] < X).sum() < 1:
      if  cost >  check[0]:
        cost = check[0]


if cost == 12*10**5+1:
  cost = -1
print(cost) 

print(ALL)

import numpy as np
import itertools

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

all_df = np.zeros((1,M+1))
for n in range(N):
  A = [int(i) for i in input().split()]
  all_df = np.vstack([all_df, np.array(A).reshape(1,-1)])

all_df = all_df[1:]

now_cost = 10**9
for bins in itertools.product([0,1], repeat=N):
  prod = all_df[np.array(bins).astype(bool)].sum(axis=0)
  #print(prod)
  if (X > prod[1:]).sum() > 0:
    pass
  else:
    if prod[0] < now_cost:
      now_cost = prod[0]

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted