TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
import os

def main():
	a,b,c,k = map(int, input().split())
	ans = 0
	ans += a
	k -= a
	k -= b
	ans += (c - k - 1) * (-1)
	

if __name__ == "__main__":
	main()


import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt, gcd
from copy import deepcopy

def main():
    a,b,c,k = map(int, input().split())

    if k <= a:
        print(k)
        sys.exit()
    elif k <= a+b:
        print(a)
        sys.exit()
    else:
        print(a+(k - a - b)*(-1))

if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
a , b ,c , k = map(int, input().split())

tmp = k -(a+b)


if (a+b) >= k:
    print(k)
elif a > 0 and (a+b) < k:
    print (a - tmp)
elif a == 0 :
    print (-(k-b))


a , b ,c , k = map(int, input().split())


tmp = k - a 
tmp2 = k -a-b

if k < a:
    print(k)
elif  tmp > 0  and tmp < b:
    print(a)
elif tmp2 != k and tmp2 > 0:
    print(a - tmp2)
else:
    print(-k)

a , b ,c , k = map(int, input().split())

tmp = k -(a+b)


if (a+b) >= k:
    print(k)
elif a > 0 and (a+b) < k:
    print (a - tmp)
elif a == 0 and b <= k:
    print (-(k-b))
elif a==0 and b > k:
    print(0)
else:
    print(-k)



a , b ,c , k = map(int, input().split())

if a >= k:
    print(k)
elif a+b >= k:
    print(a)
elif a > 0 :
    print( a - (k-a-b))
elif b > 0:
    print(-(k-b))
else:
    print(-k)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
abck = input().split(" ")
a = abck[0]
b = abck[1]
c = abck[2]
k = abck[3]

if k < a:
	print(a)
elif k < a + b:
	print(a)
else:
	print(a - (k - (a + b)))

 

abck = input().split(" ")
a = int(abck[0])
b = int(abck[1])
k = int(abck[3])

if k < a:
	print(k)
elif k <= a + b:
	print(a)
else:
	c = k - (a + b)
	print(a - c)


Verdicts: Runtime Error

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
A,B,C,K = map(int, input().split())

D = 0
if K-A-B > 0:
	D = K-A-B
if K == A:
	ans = A - D
else:
	ans = K
print(ans)

A,B,C,K = map(int, input().split())

D = 0
if K-A-B > 0:
	D = K-A-B
if K >= A:
	ans = A - D
else:
	ans = K
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
def main(A, B, C, K):
    """
    a = [1 for _ in range(A)]
    b = [0 for _ in range(B)]
    c = [-1 for _ in range(C)]
    k = a + b + c
    ans = sum(k[:K])
    """
    if A+B >= K:
        return K
    else:
        return A - (K-A-B)

if __name__ == '__main__':
    A, B, C, K = map(int, input().split())
    ans = main(A, B, C, K)
    print(ans)



def main(A, B, C, K):
    """
    a = [1 for _ in range(A)]
    b = [0 for _ in range(B)]
    c = [-1 for _ in range(C)]
    k = a + b + c
    ans = sum(k[:K])
    """
    if K <= A:
        return K
    if A <= K <= A+B:
        return A
    else:
        return A - (K-A-B)

if __name__ == '__main__':
    A, B, C, K = map(int, input().split())
    ans = main(A, B, C, K)
    print(ans)



Verdicts: Wrong Answer

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
a,b,c,k=map(int,input().split())
if a>=k:
  print(k)
elif a<k and b>=k-a:
  print(a)
else:
  print(2a+b-k)

a,b,c,k=map(int,input().split())
if a>=k:
  print(k)
elif a<k and b>=k-a:
  print(a)
else:
  print(2*a+b-k)

Verdicts: Runtime Error

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
a,b,c,k=map(int,input().split())
n=k-a-b
if n>=0 
    print(a-n)
elif n<0 and a<=k:
    print(a)
elif n<0 and a>k:
    print(k)

a,b,c,k=map(int,input().split())
n=k-a-b
if n>=0 
    print(a-n)
elif n<0 and a<=k:
    print(a)
else:
    print(k)

a,b,c,k=map(int,input().split())
n=k-a-b
if n>=0: 
    print(a-n)
elif n<0 and a<=k:
    print(a)
elif n<0 and a>k:
    print(k)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):

a, b, c, k = map(int, input().split())
cards = 0
sum = 0

if k >=a:
  sum = sum + a * 1
  cards = k - a
  if k >= b:
    sum += 0
    cards = cards + b
    if k >= c:
    	sum -= 1
    	cards = cards + c
    	print(sum)
    else:
      sum = sum + (k - cards) * -1
      print(sum)
    
    if k  
  else:
    print(sum)
else:
  sum = sum + k * 1
  print(sum)
  

a, b, c, k = map(int, input().split())

cards = k
sum = 0

while (True):
    if cards > a:
        sum += a
        cards -= a
        if cards > b:
            sum += 0
            cards -= b
            if cards > c:
                sum -= c
                cards -= b
            else:
                sum -= cards
                print(sum)
                break
        else:
            print(sum)
            break

    else:
        sum += cards
        print(sum)
        break



Verdicts: Runtime Error

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
a,b,c,d=map(int,input().split())
h=k-a
h2=h-b
if a>k:
  print(k)
else:
  if h<=b:
    print(a)
  else:
    print(a+h2*(-1))

a,b,c,d=map(int,input().split())
h=k-a
h2=h-b
if a>k:print(k)
else:if h<=b:print(a)
     else: print(a+h2*(-1))

a,b,c,k=map(int,input().split())
h=k-a
h2=h-b
if a>k:
  print(k)
else:
  if h<=b:
    print(a)
  else:
    print(a+h2*(-1))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
a,b,c,k=map(int,input().split())
 
if a>=k:
  print(a)
  exit()
else:
  if k-a=<b:
    print(a)
    exit()
  else:
    c=k-a-b
    print(a-c)

a,b,c,k=map(int,input().split())

if a>=k:
  print(a)
  break()
else:
  if k-a<b:
    print(a)
  else:
    c=k-a-b
    print(a-c)


a,b,c,k=map(int,input().split())
 
if a>=k:
  print(a)
  exit()
else:
  if k-a=<b:
    print(a)
    exit()
  else:
    c=k-a-b
    print(a-c)

a,b,c,k=map(int,input().split())
 
if a>=k:
  print(k)
  exit()
else:
  if k-a<=b:
    print(a)
    exit()
  else:
    c=k-a-b
    print(a-c)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
from sys import stdin

A, B, C, K = [int(x) for x in stdin.readline().rstrip().split()]
if K-A == 0:
    print(A)
elif K-A > 0:
    if K-A-B <= 0:
        print(A)
    else:
        print(int(A+(K-A-B)*-1))

print(int(A+(K-A-B)*-1))

from sys import stdin

A, B, C, K = [int(x) for x in stdin.readline().rstrip().split()]
countA = 0
countB = 0
countC = 0

#     print(i)

for i in range(1, A+1):
    K -= 1
    countA += 1
    if K == 0:
        break

print(countA)
print(K)

if K == 0:
    print(int(countA*1))

for i in range(1, B+1):
    K -= 1
    countB += 1
    if K == 0:
        break

if K == 0:
    print(int(countA*1 + countB*0))

for i in range(1, C+1):
    K -= 1
    countC += 1
    if K == 0:
        break

if K == 0:
    print(int(countA*1 + countB*0 + countC*-1))


from sys import stdin

A, B, C, K = [int(x) for x in stdin.readline().rstrip().split()]
if K-A <= 0:
    print(A, 'first')
elif K-A > 0:
    if K-A-B <= 0:
        print(A, 'sec')
    else:
        print(int(A+(K-A-B)*-1), 'third')

from sys import stdin
A, B, C, K = [int(x) for x in stdin.readline().rstrip().split()]
if K-A <= 0:
    print(K)
elif K-A > 0:
    if K-A-B <= 0:
        print(A)
    else:
        print(int(A+(K-A-B)*-1))


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
A,B,C,K = map(int,input().split())
answer = 0
if K <= A:
    print(K)
elif K > A:
    answer = A
    K = K - A
if K <= B and K > 0 :
    print(answer)
elif K > B:
    K = K - B
if K <= C and K > 0:
    answer = answer - K
    print(answer)

A,B,C,K = map(int,input().split())
answer = 0
if K <= A:
    print(K)
elif K > A:
    answer = A
    K = K - A
if K <= B , K > 0 :
    print(answer)
elif K > B:
    K = K - B
if K <= C,K > 0:
    answer = answer - K
    print(answer)

A,B,C,K = map(int,input().split())
answer = 0
if K <= A:
    print(K)
    K = 0
elif K > A:
    answer = A
    K = K - A
if K <= B and K > 0 :
    print(answer)
    K = 0
elif K > B:
    K = K - B
if K <= C and K > 0:
    answer = answer - K
    print(answer)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
a, b, c, k = map(int, input().split())
num = a
k -= a

if k>0:
    k-=b
    if k>0:
        print(num-k)
        exit()
    else:
        print(num)

print(num)

a, b, c, k = map(int, input().split())
num = 0

if k-a>0:
    num += a
    k-=a
    if k-b>0:
        k -= b
        print(num-k)
    else:
        print(num)
else:
    print(k)

Verdicts: Wrong Answer

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
if k<=a:
    print(k)
else:
    x = k-a
    if x<=b:
        print(a)
    else:
        print(a-(x-b))


a,b,c,k = map(int,input().split())

if k<=a:
    print(k)
else:
    x = k-a
    if x<=b:
        print(a)
    else:
        print(a-(x-b))

Verdicts: Runtime Error

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
# abc167 b
a, b, c, k = [int(i) for i in input().split()]
ans = 0
if k < a:
    ans = 0
elif k < a + b:
    ans = a
else:
    ans = a - (k-(a+b))

# abc167 b
a, b, c, k = [int(i) for i in input().split()]
ans = 0
if k <= a:
    ans = k
elif k <= a + b:
    ans = a
else:
    ans = a - (k-(a+b))
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
a,b,c,x=map(int,input().split())
 
if:
  print(x)
elif x<a+b:
  print(int(a))
else:
  print(int(2*a+b-x))

a,b,c,x=map(int,input().split())
 
if x<a:
  print(x)
elif x<a+b:
  print(a)
else:
  print(2*a+b-x)

Verdicts: Runtime Error

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
S = input()
T = input()

if(S==T[0:len(S)]):
  print(Yes)
 else:
    print(No)
	



A, B, C, K = map(int, input().split())
if((K-A)>0):
    Y = K-A
else:
    print(K)
    exit()
if((Y-B)>0):
    Z = Y-B
else:
    Z = 0

X = A + 0 * Y + (-1) * Z
print(X)











	



Verdicts: Runtime Error

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
A, B,C,K = map(int, input().split())

ans = 0

for i in range(A):
  if(K>0):
    ans = ans + 1
    K = K-1
for i in range(B):
  if(K>0):
    ans = ans 
    K = K-1
for i in range(C):
  if(K>0):
    ans = ans - 1
    K = K-1

A, B,C,K = map(int, input().split())
if(K<A):
  print(K)
elif(K>A+B):
  print(A - (K-A-B))
else:
  print(A)

Verdicts: Wrong Answer

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
a, b, c , k = map(int, input().split())
if k <=a:
    print(k)
if k <=(a+b):
    print(a)
if k < a+b+c:
    print(a-(k-(a+b)))


a, b, c , k = map(int, input().split())
if k <=a:
    print(k)
if k <=(a+b):
    print(a)
if k <= a+b+c:
    print(a-(k-(a+b)))


a, b, c , k = map(int, input().split())
if k <=a:
    print(k)
if k <=(a+b):
    print(a)
if k < a+b+c:
    print(a-c)
    

def main(a, b,c,k):

    m = 0
    if k <=a:
        m = k
    elif k <=(a+b):
        m = a
    elif k <= a+b+c:
        m = (a-(k-(a+b)))
    return m
a, b, c , k = map(int, input().split())
print(main(a,b,c,k))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
a,b,c,k = map(int,input().split())
if a >= k:
	print(k)
elif a+b >=k:
	print(k)
else:
    print(a*1+b*0 +(k-a-b)*(-1))
    



a,b,c,k = map(int,input().split())
xa = min(a,k)
k-=xa
xb=min(b,k)
k-=xb
xc=k
print(xa-xc)
    



Verdicts: Wrong Answer

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
A, B, C, K = map(int, input.split(" "))
if K <= A:
    print(K)
else:
    K = K - A
    if K <= B:
        print(A)
    else:
        K = K - B
        print(A - K)


A, B, C, K = map(int, input().split(" "))
if K <= A:
    print(K)
else:
    K = K - A
    if K <= B:
        print(A)
    else:
        K = K - B
        print(A - K)


Verdicts: Runtime Error

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
a = input()
b = input()
c = input()
k = input()

if(k<a):
    print(k)
elif(k>a and k<a+b):
    print(a)
elif(k>a+b and k<a+b+c):
    print(a-(k-(a+b)))


a, b, c, k = map(int, input().split())

if(k<=a):
    print(k)
elif(k>a and k<=a+b):
    print(a)
else:
    print(a-(k-(a+b)))


Verdicts: Runtime Error

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
from sys import stdin

a=stdin.readline().split()
A=int(a[0]) #1
B=int(a[1]) #0
C=int(a[2]) #-1
K=int(a[3])

if K<=A:
  print(K)
elif K<A<=A+B:
  print(A)
else:
  print(2*(A+B)-K)

from sys import stdin
 
a=stdin.readline().split()
A=int(a[0]) #1
B=int(a[1]) #0
C=int(a[2]) #-1
K=int(a[3])
 
if K<=A:
  print(K)
elif K<A<=A+B:
  print(A)
else:
  print(2*A+B-K)

Verdicts: Wrong Answer

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
A,B,C,K = map(int,input().split())
if A + B >= K:
	print(K)
else:
	print(A-(K-(A+B)))

A,B,C,K = map(int,input().split())
if A + B >= K:
	print(max(K,A))
else:
	print(A-(K-(A+B)))

A,B,C,K = map(int,input().split())
if A + B >= K:
	print(max(K.A))
else:
	print(A-(K-(A+B)))

A,B,C,K = map(int,input().split())
if A + B >= K:
	print(min(K,A))
else:
	print(A-(K-(A+B)))

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
A = list(map(int, input().split()))

if A[0]+A[1]+A[2]>=A[3]:
  if A[3]-A[0]-A[1]>A[2]:
  	print(A[0]-(A[3]-A[0]-A[1]))
  else:
    print(A[0]-A[2])
else:
  print(A[0]-A[2])

A = list(map(int, input().split())) 

ans=0
if A[0]<A[3]:
  ans = A[0]
else:
  ans = A[3]
  print(ans)
  
print(ans-(A[3]-A[0]-A[1])

A = list(map(int, input().split()))
 
if A[0]>=A[3]:
  print(A[3])
else:
  if A[0]+A[1]>=A[3]:
    print(A[0])
  else:
    print(A[0]-A[3]+A[0]+A[1])

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
l = map(int, input().split())
lists = [1]*l[0] + [0]*l[1] + [-1]*l[2]
sum = 0
for i in range(l[3]):
    sum += lists[i]
print(sum)

a, b, c, k = map(int, input().split())
print(a+b if a+b>=k else a-(k-a-b))

a, b, c, k = map(int, input().split())
print(a if a>=k else a-c)

a, b, c, k = map(int, input().split())
print(min(a, k, a-(k-a-b))

a, b, c, k = map(int, input().split())
print(min(a, k, a*2+b-k))

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
import math
sys.setrecursionlimit(10**9)

def main():
    A,B,C,K = map(int,input().split())

    if K<= A:
        print(K)
    elif K<=B:
        print(A)
    else:
        print(2*A+B-K)

if __name__ == "__main__":
  main()

import sys
import math
sys.setrecursionlimit(10**9)

def main():
    A,B,C,K = map(int,input().split())

    if K<= A:
        print(K)
    elif K<=B:
        print(A)
    else:
        print(2*A+B-K)

if __name__ == "__main__":
  main()


Verdicts: Runtime Error

Accepted
Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
A, B, C, K = inpl()
if A >= K:
    print(K)
    exit()
if A+B >= K:
    print(A)
    exit()
print(A-(K-A-B))

from collections import defaultdict, deque
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

A, B, C, K = inpl()
if A >= K:
    print(K)
    exit()
if A+B >= K:
    print(A)
    exit()

print(A - (K-A-B))

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):
N, M, X = list(map(int, input().split()))
CA = [list(map(int, input().split())) for i in range(N)]
# print(N, M, X)
# print(CA)

def can_reach(M, CA, X):
    understandig_list = [0] * M
    for CAi in CA:
        for j in range(1, len(CAi)):
            understandig_list[j - 1] += CAi[j] 

    can = all([understandig >= X for understandig in understandig_list])

    return can


if not can_reach(M, CA, X):
    print('-1')
    exit(0)

print(0)


import itertools


N, M, X = list(map(int, input().split()))
CA = [list(map(int, input().split())) for i in range(N)]
# print(N, M, X)
# print(CA)

INF = 10 ** 5 * 12 + 1
min_amount = INF
for i in range(1, N + 1):
    combinations = itertools.combinations(range(N), i)

    for combination in combinations:
        understanding_list = [0] * M
        amount = 0
        for i in combination:
            for j in range(1, len(CA[i])):
                understanding_list[j - 1] += CA[i][j]
            amount += CA[i][0]

        
        is_reached = all([understanding >= X for understanding in understanding_list])
        if not is_reached: continue

        min_amount = min(amount, min_amount)

answer = -1 if min_amount == INF else min_amount

print(answer)


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())
books = [0]*n
for i in range(n):
  books[i] = [int(x) for x in input().split()]

ans = 10**9
for i in range(2**n):
  cost = 0
  point = [0]*m
  for j in range(n):
    if (i>>j)&1:
      for k in range(1, m+1):
        point[k-1] += books[j][k]
  flag = True
  for j in range(m):n, m, x = map(int, input().split())
books = [0]*n
for i in range(n):
  books[i] = [int(x) for x in input().split()]

ans = 10**9
for i in range(2**n):
  cost = 0
  point = [0]*m
  for j in range(n):
    if (i>>j)&1:
      cost += books[j][0]
      for k in range(1, m+1):
        point[k-1] += books[j][k]
  flag = True
  for j in range(m):
    if point[j] < x:
      flag = False
  if flag and ans > cost:
    ans = cost

print(ans if ans != 10**9 else -1)
    if point[j] < x:
      flag = False
  if flag and ans > cost:
    ans = cost

print(ans if ans != 10**9 else -1)

n, m, x = map(int, input().split())
books = [0]*n
for i in range(n):
  books[i] = [int(x) for x in input().split()]

ans = 10**9
for i in range(2**n):
  cost = 0
  point = [0]*m
  for j in range(n):
    if (i>>j)&1:
      cost += books[j][0]
      for k in range(1, m+1):
        point[k-1] += books[j][k]
  flag = True
  for j in range(m):
    if point[j] < x:
      flag = False
  if flag and ans > cost:
    ans = cost

print(ans if ans != 10**9 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 numpy as np

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

a = np.zeros((N,M+1))

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

b = np.zeros(N)
c = np.zeros(M+1)
min_cost = 9999999999999999

for i in range(2**N):
    ii = i
    for j in range(N):
        b[j] = ii % 2
        ii = ii // 2
    c = np.zeros(M+1)
    flg = "ok"
    for k in range(M+1):
        for j in range(N):
            c[k] += a[j,k] * b[j]
        if k > 0 and c[k] < X:
            flg = "ng"
            continue
    if flg == "ok":
        min_cost = min(min_cost,c[0])

if min_cost == 9999999999999999:
    print(-1)
else:
    print(min_cost)


            

import numpy as np

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

a = np.zeros((N,M+1))

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

b = np.zeros(N)
c = np.zeros(M+1)
min_cost = 9999999999999999

for i in range(2**N):
    ii = i
    for j in range(N):
        b[j] = ii % 2
        ii = ii // 2
    c = np.zeros(M+1)
    flg = "ok"
    for k in range(M+1):
        for j in range(N):
            c[k] += a[j,k] * b[j]
        if k > 0 and c[k] < X:
            flg = "ng"
            continue
    if flg == "ok":
        min_cost = min(min_cost,c[0])

if min_cost == 9999999999999999:
    print(-1)
else:
    print(int(min_cost))


            

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=[]
for i in range(N):
    A.append(list(map(int, input().split())))
    
pr=10**9
for s in range(2**N):
    x_m = [0]*13
    for i in range(N):
        b = (s >> i) & 1
        if b == 1:
            pr_s += A[i][0]
            for j in range(M+1):
                x_m[j] += A[i][j]

    xOk = True
    for j in range(1,M+1):
        if x_m[j] < X:
            xOk = False
    
    if xOk == True:
        pr = min(pr, x_m[0])

if pr<10**9:
    print(pr)
else:
    print(-1)

N, M, X = map(int,input().split())
A=[]
for i in range(N):
    A.append(list(map(int, input().split())))
    
pr=10**9
for s in range(2**N):
    x_m = [0]*13
    for i in range(N):
        b = (s >> i) & 1
        if b == 1:
            pr_s += A[i][0]
            for j in range(M+1):
                x_m[j] += A[i][j]
 
    xOk = True
    for j in range(1,M+1):
        if x_m[j] < X:
            xOk = False
    
    if xOk == True:
        pr = min(pr, x_m[0])
 
if pr<10**9:
    print(pr)
else:
    print(-1)

N, M, X = map(int,input().split())
A=[]
for i in range(N):
    A.append(list(map(int, input().split())))
    
pr=10**9
for s in range(2**N):
    x_m = [0]*13
    for i in range(N):
        b = (s >> i) & 1
        if b == 1:
            for j in range(M+1):
                x_m[j] += A[i][j]
 
    xOk = True
    for j in range(1,M+1):
        if x_m[j] < X:
            xOk = False
    
    if xOk == True:
        pr = min(pr, x_m[0])
 
if pr<10**9:
    print(pr)
else:
    print(-1)

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())
A = [0]*M
C = []
Z = []
cz = []
b = 0
for i in range(N) :
    C.append(list(map(int,input().split())))

for i in range(1,N+1) :
    c = list(itertools.combinations(C,i))
    print(c)
    for j in range(len(c)) :
        A=[0]*M
        cj = c[j]
        for k in range(i) :
            ck = cj[k]
            for l in range(M) :
                A[l]+= ck[l]        
        for m in range(1,M) :
            if A[m] < X :
                break
            cz.append(A[0])

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

import numpy
N,M,X = map(int,input().split())
A = numpy.array([[int(i) for i in input().split()] for _ in range(N)])
ans = 10**8
for i in range(2**N) :
    i = format(i,'b').zfill(N)
    check = numpy.array([0]*(M+1))
    for j in range(N) :
        if i[j] == '0' :
            continue
        check +=  A[j][0:]
    if all (check[m] >= X for m in range(1,M+1)) :
        ans = min(ans,check[0])

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())
items = [list(map(int,input().split())) for _ in range(N)]
ans = -1
for i in range(1 << N):
    total = [0]*(M+1)
    for j in range(N):  
        if ((i >> j) & 1):  
            h = [x + y for (x, y) in zip(total, items[j])]
    # print(total)
    if all( k >= X for k in h[1:]) == True:
        if ans == -1:
            ans = h[0]
        else:
            ans = min(ans,total[0]) 
print(ans)





N,M,X = map(int,input().split())
items = [list(map(int,input().split())) for _ in range(N)]
ans = -1
for i in range(1 << N):
    total = [0]*(M+1)
    for j in range(N):  
        if ((i >> j) & 1):  
            total = [x + y for (x, y) in zip(total, items[j])]
    # print(total)
    if all( k >= X for k in total[1:]) == True:
        if ans == -1:
            ans = total[0]
        else:
            ans = min(ans,total[0]) 
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 numpy as np

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

CA = []
for i in range(N):
    s = input()
    CA.append(np.fromstring(s, np.int16, sep=" "))

CA = np.asarray(CA)
C = CA[:, :1]
A = CA[:, 1:]

def loop(i, x, total):
    if i == N:
        if (x >= X).all():
            return total
        else:
            return np.inf

    return min(loop(i+1, x, total), loop(i+1, x+A[i], total+C[i]))

ans = loop(0, np.zeros_like(A[0]), 0)
if ans == np.inf:
    print(-1)
else:
    print(ans)

import numpy as np

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

CA = []
for i in range(N):
    s = input()
    CA.append(np.fromstring(s, np.int64, sep=" "))

CA = np.asarray(CA)
C = CA[:, :1]
A = CA[:, 1:]

def loop(i, x, total):
    if i == N:
        if (x >= X).all():
            return total
        else:
            return np.inf

    return min(loop(i+1, x, total), loop(i+1, x+A[i], total+C[i]))

ans = loop(0, np.zeros_like(A[0]), 0)
if ans == np.inf:
    print(-1)
else:
    print(ans)

import numpy as np

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

CA = []
for i in range(N):
    s = input()
    CA.append(np.fromstring(s, np.int64, sep=" "))

CA = np.asarray(CA)
C = CA[:, 0]
A = CA[:, 1:]

def loop(i, x, total):
    if i == N:
        if (x >= X).all():
            return total
        else:
            return np.inf

    return min(
        loop(i+1, x, total),
        loop(i+1, (x+A[i]).clip(0, X), total+C[i])
    )

ans = loop(0, np.zeros_like(A[0]), 0)
if ans == np.inf:
    print(-1)
else:
    print(ans)

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())]
k = []
ans = 10 ** 6
for i in range(n):
    c, *a = [*map(int, input().split())]
    s += c
    k.append([c, *a])

for i in range(2 ** n):
    cost = 0
    skills = [0] * m
    for j in range(n):
        if ((i >> j) & 1):
            cost += k[j][0]
            for s, t in enumerate(k[j][1:]):
                skills[s] += t
            if all(map(lambda skill: skill >= x, skills)):
                ans = min(ans, cost)
print(-1 if ans == 10 ** 6 else ans)

n, m, x = [*map(int, input().split())]
k = [[*map(int, input().split())] for _ in range(n)]
ans = 10 ** 9

for i in range(2 ** n):
    cost = 0
    skills = [0] * m
    for j in range(n):
        if ((i >> j) & 1):
            cost += k[j][0]
            for s, t in enumerate(k[j][1:]):
                skills[s] += t
            if all(map(lambda skill: skill >= x, skills)):
                ans = min(ans, cost)
print(-1 if ans == 10 ** 9 else 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):
N, M, X = map(int,input().split())
a=[]
b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
c=[]
for i in range(N):
    a.append(input().split())
    c.append(0)

check=0
ans=-1
for i in range(1,(2**N)-1):
    b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    check=0
    for j in range(N):
        if 0x01 & (i >> j):
            for n in range(M+1):
                b[n] = b[n] + int(a[j][n])
        for k in range(1,M):
            if b[k] < X:
                check=1
                break
    if check==0:
        #print(ans)
        if ans == -1 or ans > b[0]:
            ans = b[0]
print(ans)


N, M, X = map(int,input().split())
a=[]
b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
c=[]
for i in range(N):
    a.append(input().split())
    c.append(0)

check=0
ans=-1
for i in range(2**N):
    b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    for j in range(N):
        if 0x01 & (i >> j):
            for n in range(M+1):
                b[n] = b[n] + int(a[j][n])

        check=0
        print(b)
        for k in range(1,M):
            if b[k] < X:
                check=1

        if check==0:
            if ans == -1 or ans > b[0]:
                ans = b[0]

print(ans)


N, M, X = map(int,input().split())
a=[]
b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
c=[]
for i in range(N):
    a.append(input().split())
    c.append(0)

check=0
ans=-1
for i in range(2**N):
    b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    for j in range(N):
        if 0x01 & (i >> j):
            for n in range(M+1):
                b[n] = b[n] + int(a[j][n])

        check=0
        print(b)
        for k in range(1,M):
            if b[k] < X:
                check=1

        if check==0:
            if ans == -1 or ans > b[0]:
                ans = b[0]

print(ans)


N, M, X = map(int,input().split())
a=[]
b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

for i in range(N):
    a.append(input().split())

check=0
ans=-1
for i in range(1,pow(2,N)):
    b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    check=0
    for j in range(N):
        if 0x01 & (i >> j):
            for n in range(M+1):
                b[n] = b[n] + int(a[j][n])
    for k in range(1,M+1):
        if b[k] < X:
            check=1
    if check==0:
        if ans == -1 or ans > b[0]:
            ans = b[0]
print(ans)

Verdicts: Wrong Answer

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 for i in range(N)]
A=[[] for i in range(N)]
min_cost=10000000000
for i in range(N):
    C[i],*A[i]=map(int,input().split())
for i in range(1<<N):
    L=[0 for i in range(M)]
    cost=0
    for j in range(N):
        if 1&(i>>j):
            for k in range(M):
                L[k]+=A[j][k]
            cost+=C[j]
    if min(L)>=X:
      min_cost=min(min_cost,cost)
if min_cost=10000000000:
  print(-1)
else:
  print(min_cost)

N,M,X = map(int,input().split())
C=[0 for i in range(N)]
A=[[] for i in range(N)]
min_cost=10000000000
for i in range(N):
    C[i],*A[i]=map(int,input().split())
for i in range(1<<N):
    L=[0 for i in range(M)]
    cost=0
    for j in range(N):
        if 1&(i>>j):
            for k in range(M):
                L[k]+=A[j][k]
            cost+=C[j]
    if min(L)>=X:
      min_cost=min(min_cost,cost)
if min_cost==10000000000:
  print(-1)
else:
  print(min_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):

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

ans = -1
for i in range(2**n):
    li = [0]*(m+1)
    print('＝＝＝＝＝＝＝＝＝＝')
    for j in range(n):
        print('i = ', i)
        print('j = ', j)
        print('(i >> j) = ', (i >> j))
        print('((i >> j) & 1) = ', ((i >> j) & 1))
        if ((i >> j) & 1):
            for k in range(m+1):
                li[k] += ca[j][k]
        print('li = ', li)
    for j in range(1, m+1):
        if li[j] < x:
            break
    else:
        if ans == -1:
            ans = li[0]
        else:
            if ans > li[0]:
                ans = li[0]
print(ans)



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

ans = -1
for i in range(2**n):
    li = [0]*(m+1)
    
    for j in range(n):
        # print('i = ', i)
        # print('j = ', j)
        # print('(i >> j) = ', (i >> j))
        # print('((i >> j) & 1) = ', ((i >> j) & 1))
        if ((i >> j) & 1):
            for k in range(m+1):
                li[k] += ca[j][k]
        # print('li = ', li)
    for j in range(1, m+1):
        if li[j] < x:
            break
    else:
        if ans == -1:
            ans = li[0]
        else:
            if ans > li[0]:
                ans = li[0]
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):
def main()
    n, m, x = map(int, input().split())
    ca = []
    for _ in range(n):
        ca.append(list(map(int, input().split())))
    result = 10**9
    for i in range(1, 2**n+1):
        work = 0
        j = 0
        temp = [0] * m
        for flag in bin(i)[2:].zfill(n):
            if flag == "1":
                work += ca[j][0]
                for k in range(1, m+1):
                    temp[k-1] += ca[j][k]
            j += 1
        flag = True
        for t in temp:
            if t < x:
                flag = False
                break
        if flag:
            result = min(result, work)
    if result == 10**9:
        print(-1)
    else:
        print(result)
main()

def main():
    n, m, x = map(int, input().split())
    ca = []
    for _ in range(n):
        ca.append(list(map(int, input().split())))
    result = 10**9
    for i in range(1, 2**n+1):
        work = 0
        j = 0
        temp = [0] * m
        for flag in bin(i)[2:].zfill(n):
            if flag == "1":
                work += ca[j][0]
                for k in range(1, m+1):
                    temp[k-1] += ca[j][k]
            j += 1
        flag = True
        for t in temp:
            if t < x:
                flag = False
                break
        if flag:
            result = min(result, work)
    if result == 10**9:
        print(-1)
    else:
        print(result)
main()

Verdicts: Runtime Error

Accepted