Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
def Skill_Up():
    condition = input()
    condition_list = condition.split()
    N = int(condition_list[0])
    M = int(condition_list[1])
    X = int(condition_list[2])
    
    text_info=[]
    for i in range(0, N):
        text_book = input()
        text_info_str = text_book.split()
        text_book_int = []
        for j in text_info_str:
            text_book_int.append(int(j))
        text_info.append(text_book_int)
    
    text_effective = []
    for i in text_info:
        effective = 0
        for j in range(1, M+1):
            effective += i[j]
        effective /= i[0]
        text_effective.append(effective)
    
    for i in range(0, N):
        for j in range(0, N - i - 1):
            if text_effective[j] < text_effective[j+1]:
                text_effective[j], text_effective[j+1] = text_effective[j+1], text_effective[j]
                text_info[j], text_info[j+1] = text_info[j+1], text_info[j]
    
    skill_level = []
    skill_check = []
    for j in range(0, M+1):
        skill_level.append(0)
        skill_check.append(False)
    
    is_clear = False
    for i in range(0, N):
        for j in range(0, M+1):
            skill_level[j] += text_info[i][j]
            if skill_level[j] >= X:
                skill_check[j] = True
        for j in range(0, M+1):
            if skill_check[j] is False:
                is_clear = False
                break
            is_clear = True
    
    if is_clear:
        print(skill_level[0])
    else:
        print(-1)
    
Skill_Up()

if __name__ == '__main__':
    n, m, x = list(map(int, input().split()))
    
    c = []
    a = []
    
    def calc_price(bit):
        price_total = 0
        learn_total = [0] * m 
        
        for i in range(n):
            if (bit >> i) & 1:
                price_total += c[i]
                learn = a[i]
                for j, la in enumerate(learn):
                    learn_total[j] += la
        
        if check(learn_total):
            return price_total
        else:
            return INF
        
    def check(learn_total):
        for i in range(m):
            if learn_total[i] < x:
                return False
        return True
    
    for i in range(n):
        c_temp, *a_temp = list(map(int, input().split()))
        c.append(c_temp)
        a.append(a_temp)
        
    INF = float("inf")
    ans = INF
    
    for bit in range(1 << n):
        price = calc_price(bit)
        ans = min(ans, price)
    
    if ans == INF:
        print(-1)
    else:
        print(ans)

Verdicts: Wrong Answer

Accepted