problem_id
stringlengths
6
6
user_id
stringlengths
10
10
time_limit
float64
1k
8k
memory_limit
float64
262k
1.05M
problem_description
stringlengths
48
1.55k
codes
stringlengths
35
98.9k
status
stringlengths
28
1.7k
submission_ids
stringlengths
28
1.41k
memories
stringlengths
13
808
cpu_times
stringlengths
11
610
code_sizes
stringlengths
7
505
p02682
u901582103
2,000
1,048,576
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?
['if a>=k:\n print(k)\nelif a<k<=a+b:\n print(a)\nelse:\n print(a-(k-a-b))', 'a,b,c,k=map(int,input().split())\nif a>=k:\n print(k)\nelif a<k<=a+b:\n print(a)\nelse:\n print(a-(k-a-b))\n']
['Runtime Error', 'Accepted']
['s190783789', 's275109900']
[9088.0, 9156.0]
[19.0, 23.0]
[76, 110]
p02682
u904811150
2,000
1,048,576
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?
['if a.isdigit()==True and b.isdigit()==True and c.isdigit()==True and k.isdigit()==True:\n a = int(a)\n b = int(b)\n c = int(c)\n k = int(k)\n if a>=0 and b>=0 and c>=0:\n if k>=1 and k<=(a+b+c) and (a+b+c)<=2*(10**9):\n if k < a:\n print(k)\n elif k >= a and k <= (a+b):\n print(a)\n else:\n print(a - (k - b - a))', 'a, b, c, k = map(int, input().split())\n\nif a.isdigit()==True and b.isdigit()==True and c.isdigit()==True and k.isdigit()==True:\n a = int(a)\n b = int(b)\n c = int(c)\n k = int(k)\n if k>=1 and k<=(a+b+c) and (a+b+c)<=2*(10**9):\n if k <= a:\n print(k)\n elif k > a and k <= (a+b):\n print(a)\n else:\n print(a - (k - b - a))', 'if a.isdigit()==True and b.isdigit()==True and c.isdigit()==True and k.isdigit()==True:\n a = int(a)\n b = int(b)\n c = int(c)\n k = int(k)\n if a>=0 and b>=0 and c>=0 and k>=1 and k<=(a+b+c) and (a+b+c)<=2*(10**9):\n if k < a:\n print(k)\n elif k >= a and k <= (a+b):\n print(a)\n else:\n print(a - (k - b - a))', 'if a.isdigit()==True and b.isdigit()==True and c.isdigit()==True and k.isdigit()==True:\n a = int(a)\n b = int(b)\n c = int(c)\n k = int(k)\n if a>=0 and b>=0 and c>=0 and k>=1 and k<=(a+b+c) and (a+b+c)<=2*(10**9):\n if k < a:\n print(k)\n elif k >= a and k <= (a+b):\n print(a)\n else:\n print(a - (k - b - a))', 'a, b, c, k = map(int, input().split())\n\nresult = 0\nt = min(a, k)\nresult += t\nk -= t\nt = min(b, k)\nk -= t\nt = min(c, k)\nresult -= t\nprint(result)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s342980316', 's411127804', 's661027003', 's863525059', 's290185742']
[9124.0, 9080.0, 9016.0, 9132.0, 9136.0]
[25.0, 26.0, 22.0, 22.0, 20.0]
[402, 383, 370, 370, 144]
p02682
u904995051
2,000
1,048,576
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?
['#ABC167B\na,b,c,d,k = map(int,input().split())\nprint(min(a,k)-max(k-a-b,0))', '#ABC167B\na,b,c,k = map(int,input().split())\nprint(min(a,k)-max(k-a-b,0))']
['Runtime Error', 'Accepted']
['s045142244', 's647736385']
[9152.0, 9068.0]
[22.0, 27.0]
[74, 72]
p02682
u905174677
2,000
1,048,576
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?
['a,b,c,k = map(int,input().split())\n\ndef choice2(a,b,c,k):\n if a >= k and a +b < k:\n print(a)\n elif a + b >= k and a + b + c <k:\n print(a)\n else:\n print(a-(k-c))\n\nchoice2(a,b,c,k)', 'a,b,c,k = map(int,input().split())\n\nxa = min(a,k)\nk1 = k-xa\nxb = min(b,k1)\nk2 = k1-xb\nxc = k2\n\nprint(xa-xc)']
['Wrong Answer', 'Accepted']
['s032147522', 's373153563']
[9040.0, 9108.0]
[23.0, 25.0]
[208, 107]
p02682
u907446975
2,000
1,048,576
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?
['a,b,c,k=map(int,input().split())\nif k<=a+c:\n print(k)\nelif k>a+c:\n print(a+c)', 'def do():\n a,b,c,k=map(int,input().split())\n if a>=k:\n return k\n elif a+b>=k:\n return a\n elif k>a+b:\n v=min(k-a-b,c)\n return a-v\nprint(do())\n']
['Wrong Answer', 'Accepted']
['s802450754', 's346051666']
[9164.0, 9080.0]
[23.0, 23.0]
[83, 181]
p02682
u913392095
2,000
1,048,576
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?
['\n\n#b b <B\n#c K-a-b <C \nif K < A:\n ans=K\nelif K-A <= B and K>=A:\n ans=A\nelse :\n ans=A-(K-A-B)\nprint(ans)', 'A,B,C,K=map(int,input().split())\n\n\n#b b <B\n#c K-a-b <C \nif K < A:\n ans=K\nelif K-A <= B and K>=A:\n ans=A\nelse :\n ans=A-(K-A-B)\nprint(ans)']
['Runtime Error', 'Accepted']
['s412593837', 's928915507']
[9048.0, 8904.0]
[22.0, 23.0]
[119, 167]
p02682
u917444023
2,000
1,048,576
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?
['a,b,c,k=map(int,input().split())\nif k<=a+b:\n print(k)\nelse:\n print(2*a+b-k)', 'a,b,c,k=map(int,input().split())\nif k<=a:\n print(k)\nelif a<k<=a+b:\n print(a)\nelse:\n print(2*a+b-k)']
['Wrong Answer', 'Accepted']
['s291389748', 's070801716']
[9160.0, 9164.0]
[21.0, 22.0]
[81, 107]
p02682
u917734688
2,000
1,048,576
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?
['A,B,C,D = map(int,input().split())\ncount = 0\npoint = 0\n\nif D-A <= 0:\n point = A\n D -= A\n if D-B <= 0:\n D -= B\n if D-C <= 0:\n point -= C\n print(point)\n else:\n point -= D\n print(point)\n else:\n print(point)\nelse:\n point = D\n print(point)', 'A,B,C,D = map(int,input().split())\ncount = 0\npoint = 0\n\nif D-A >= 0:\n point = A\n D -= A\n if D-B >= 0:\n D -= B\n if D-C >= 0:\n point -= C\n print(point)\n else:\n point -= D\n print(point)\n else:\n print(point)\nelse:\n point = D\n print(point)']
['Wrong Answer', 'Accepted']
['s991682105', 's267991304']
[9132.0, 9196.0]
[20.0, 20.0]
[324, 324]
p02682
u921156673
2,000
1,048,576
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?
['A, B, C, K = map(int, input().split())\n\nA = max(A, K)\nB = max(K - A, B)\nC = max(K - A - B, C)\nassert A + B + C >= K\nprint(A - C)A, B, C, K = map(int, input().split())\n\nA = min(A, K)\nB = min(K - A, B)\nC = min(K - A - B, C)\nassert A + B + C >= K\n#print(A, B, C)\nprint(A - C)', 'A, B, C, K = map(int, input().split())\n\nA = min(A, K)\nB = min(K - A, B)\nC = min(K - A - B, C)\nassert A + B + C >= K\n#print(A, B, C)\nprint(A - C)']
['Runtime Error', 'Accepted']
['s142615756', 's325770487']
[8992.0, 9000.0]
[23.0, 27.0]
[352, 184]
p02682
u927373043
2,000
1,048,576
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?
['A, B, C, K = map(int,input().split())\n\nif(A >= K):\n print(K)\nif(A+B>=K):\n print(A)\nif(A+B+C>=K):\n print(A-(K-A-B))', 'A, B, C, K = map(int,input().split())\n\nif(A >= K):\n print(K)\nelif(A+B>=K):\n print(A)\nelse:\n print(A-(K-A-B))']
['Wrong Answer', 'Accepted']
['s822667302', 's031017653']
[9172.0, 9168.0]
[21.0, 20.0]
[117, 111]
p02682
u928758473
2,000
1,048,576
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?
['import os\n\ndef main():\n\ta,b,c,k = map(int, input().split())\n\tans = 0\n\tans += a\n\tk -= a\n\tk -= b\n\tans += (c - k - 1) * (-1)\n\t\n\nif __name__ == "__main__":\n\tmain()\n', 'import os\nimport sys\nfrom collections import defaultdict, Counter\nfrom itertools import product, permutations,combinations, accumulate\nfrom operator import itemgetter\nfrom bisect import bisect_left,bisect\nfrom heapq import heappop,heappush,heapify\nfrom math import ceil, floor, sqrt, gcd\nfrom copy import deepcopy\n\ndef main():\n a,b,c,k = map(int, input().split())\n\n if k <= a:\n print(k)\n sys.exit()\n elif k <= a+b:\n print(a)\n sys.exit()\n else:\n print(a+(k - a - b)*(-1))\n\nif __name__ == "__main__":\n main()']
['Wrong Answer', 'Accepted']
['s786724398', 's677285653']
[9172.0, 9524.0]
[24.0, 26.0]
[160, 556]
p02682
u931011688
2,000
1,048,576
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?
['a , b ,c , k = map(int, input().split())\n\ntmp = k -(a+b)\n\n\nif (a+b) >= k:\n print(k)\nelif a > 0 and (a+b) < k:\n print (a - tmp)\nelif a == 0 :\n print (-(k-b))\n', 'a , b ,c , k = map(int, input().split())\n\n\ntmp = k - a \ntmp2 = k -a-b\n\nif k < a:\n print(k)\nelif tmp > 0 and tmp < b:\n print(a)\nelif tmp2 != k and tmp2 > 0:\n print(a - tmp2)\nelse:\n print(-k)', 'a , b ,c , k = map(int, input().split())\n\ntmp = k -(a+b)\n\n\nif (a+b) >= k:\n print(k)\nelif a > 0 and (a+b) < k:\n print (a - tmp)\nelif a == 0 and b <= k:\n print (-(k-b))\nelif a==0 and b > k:\n print(0)\nelse:\n print(-k)\n\n', 'a , b ,c , k = map(int, input().split())\n\nif a >= k:\n print(k)\nelif a+b >= k:\n print(a)\nelif a > 0 :\n print( a - (k-a-b))\nelif b > 0:\n print(-(k-b))\nelse:\n print(-k)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s110584508', 's702009323', 's789359868', 's007654176']
[9168.0, 9180.0, 9124.0, 9184.0]
[22.0, 20.0, 20.0, 24.0]
[166, 222, 231, 180]
p02682
u931224873
2,000
1,048,576
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?
['abck = input().split(" ")\na = abck[0]\nb = abck[1]\nc = abck[2]\nk = abck[3]\n\nif k < a:\n\tprint(a)\nelif k < a + b:\n\tprint(a)\nelse:\n\tprint(a - (k - (a + b)))\n\n ', 'abck = input().split(" ")\na = int(abck[0])\nb = int(abck[1])\nk = int(abck[3])\n\nif k < a:\n\tprint(k)\nelif k <= a + b:\n\tprint(a)\nelse:\n\tc = k - (a + b)\n\tprint(a - c)\n']
['Runtime Error', 'Accepted']
['s489431403', 's781920168']
[9104.0, 9148.0]
[23.0, 22.0]
[155, 162]
p02682
u931394483
2,000
1,048,576
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?
['A,B,C,K = map(int, input().split())\n\nD = 0\nif K-A-B > 0:\n\tD = K-A-B\nif K == A:\n\tans = A - D\nelse:\n\tans = K\nprint(ans)', 'A,B,C,K = map(int, input().split())\n\nD = 0\nif K-A-B > 0:\n\tD = K-A-B\nif K >= A:\n\tans = A - D\nelse:\n\tans = K\nprint(ans)']
['Wrong Answer', 'Accepted']
['s088334007', 's938350776']
[9176.0, 9176.0]
[21.0, 24.0]
[117, 117]
p02682
u931489673
2,000
1,048,576
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?
['def main(A, B, C, K):\n """\n a = [1 for _ in range(A)]\n b = [0 for _ in range(B)]\n c = [-1 for _ in range(C)]\n k = a + b + c\n ans = sum(k[:K])\n """\n if A+B >= K:\n return K\n else:\n return A - (K-A-B)\n\nif __name__ == \'__main__\':\n A, B, C, K = map(int, input().split())\n ans = main(A, B, C, K)\n print(ans)\n\n', 'def main(A, B, C, K):\n """\n a = [1 for _ in range(A)]\n b = [0 for _ in range(B)]\n c = [-1 for _ in range(C)]\n k = a + b + c\n ans = sum(k[:K])\n """\n if K <= A:\n return K\n if A <= K <= A+B:\n return A\n else:\n return A - (K-A-B)\n\nif __name__ == \'__main__\':\n A, B, C, K = map(int, input().split())\n ans = main(A, B, C, K)\n print(ans)\n\n']
['Wrong Answer', 'Accepted']
['s538120694', 's804916177']
[9116.0, 9052.0]
[27.0, 24.0]
[353, 390]
p02682
u932868243
2,000
1,048,576
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?
['a,b,c,k=map(int,input().split())\nif a>=k:\n print(k)\nelif a<k and b>=k-a:\n print(a)\nelse:\n print(2a+b-k)', 'a,b,c,k=map(int,input().split())\nif a>=k:\n print(k)\nelif a<k and b>=k-a:\n print(a)\nelse:\n print(2*a+b-k)']
['Runtime Error', 'Accepted']
['s974632031', 's173952523']
[9040.0, 9172.0]
[24.0, 21.0]
[106, 107]
p02682
u938718404
2,000
1,048,576
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?
['a,b,c,k=map(int,input().split())\nn=k-a-b\nif n>=0 \n print(a-n)\nelif n<0 and a<=k:\n print(a)\nelif n<0 and a>k:\n print(k)', 'a,b,c,k=map(int,input().split())\nn=k-a-b\nif n>=0 \n print(a-n)\nelif n<0 and a<=k:\n print(a)\nelse:\n print(k)', 'a,b,c,k=map(int,input().split())\nn=k-a-b\nif n>=0: \n print(a-n)\nelif n<0 and a<=k:\n print(a)\nelif n<0 and a>k:\n print(k)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s317225874', 's960816828', 's031331193']
[8940.0, 8976.0, 9140.0]
[23.0, 20.0, 23.0]
[127, 115, 128]
p02682
u939949527
2,000
1,048,576
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?
['\na, b, c, k = map(int, input().split())\ncards = 0\nsum = 0\n\nif k >=a:\n sum = sum + a * 1\n cards = k - a\n if k >= b:\n sum += 0\n cards = cards + b\n if k >= c:\n \tsum -= 1\n \tcards = cards + c\n \tprint(sum)\n else:\n sum = sum + (k - cards) * -1\n print(sum)\n \n if k \n else:\n print(sum)\nelse:\n sum = sum + k * 1\n print(sum)\n ', 'a, b, c, k = map(int, input().split())\n\ncards = k\nsum = 0\n\nwhile (True):\n if cards > a:\n sum += a\n cards -= a\n if cards > b:\n sum += 0\n cards -= b\n if cards > c:\n sum -= c\n cards -= b\n else:\n sum -= cards\n print(sum)\n break\n else:\n print(sum)\n break\n\n else:\n sum += cards\n print(sum)\n break\n\n']
['Runtime Error', 'Accepted']
['s011755146', 's984503787']
[8808.0, 9200.0]
[21.0, 20.0]
[363, 488]
p02682
u942356554
2,000
1,048,576
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?
['a,b,c,d=map(int,input().split())\nh=k-a\nh2=h-b\nif a>k:\n print(k)\nelse:\n if h<=b:\n print(a)\n else:\n print(a+h2*(-1))', 'a,b,c,d=map(int,input().split())\nh=k-a\nh2=h-b\nif a>k:print(k)\nelse:if h<=b:print(a)\n else: print(a+h2*(-1))', 'a,b,c,k=map(int,input().split())\nh=k-a\nh2=h-b\nif a>k:\n print(k)\nelse:\n if h<=b:\n print(a)\n else:\n print(a+h2*(-1))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s109452355', 's924333654', 's844102841']
[9172.0, 8872.0, 9172.0]
[18.0, 24.0, 21.0]
[123, 111, 123]
p02682
u944886577
2,000
1,048,576
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?
['a,b,c,k=map(int,input().split())\n \nif a>=k:\n print(a)\n exit()\nelse:\n if k-a=<b:\n print(a)\n exit()\n else:\n c=k-a-b\n print(a-c)', 'a,b,c,k=map(int,input().split())\n\nif a>=k:\n print(a)\n break()\nelse:\n if k-a<b:\n print(a)\n else:\n c=k-a-b\n print(a-c)\n', 'a,b,c,k=map(int,input().split())\n \nif a>=k:\n print(a)\n exit()\nelse:\n if k-a=<b:\n print(a)\n exit()\n else:\n c=k-a-b\n print(a-c)', 'a,b,c,k=map(int,input().split())\n \nif a>=k:\n print(k)\n exit()\nelse:\n if k-a<=b:\n print(a)\n exit()\n else:\n c=k-a-b\n print(a-c)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s175272943', 's314776430', 's628621770', 's240923264']
[8912.0, 8972.0, 8784.0, 9204.0]
[29.0, 27.0, 24.0, 26.0]
[141, 130, 141, 141]
p02682
u948050032
2,000
1,048,576
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?
['from sys import stdin\n\nA, B, C, K = [int(x) for x in stdin.readline().rstrip().split()]\nif K-A == 0:\n print(A)\nelif K-A > 0:\n if K-A-B <= 0:\n print(A)\n else:\n print(int(A+(K-A-B)*-1))\n\nprint(int(A+(K-A-B)*-1))', 'from sys import stdin\n\nA, B, C, K = [int(x) for x in stdin.readline().rstrip().split()]\ncountA = 0\ncountB = 0\ncountC = 0\n\n# print(i)\n\nfor i in range(1, A+1):\n K -= 1\n countA += 1\n if K == 0:\n break\n\nprint(countA)\nprint(K)\n\nif K == 0:\n print(int(countA*1))\n\nfor i in range(1, B+1):\n K -= 1\n countB += 1\n if K == 0:\n break\n\nif K == 0:\n print(int(countA*1 + countB*0))\n\nfor i in range(1, C+1):\n K -= 1\n countC += 1\n if K == 0:\n break\n\nif K == 0:\n print(int(countA*1 + countB*0 + countC*-1))\n', "from sys import stdin\n\nA, B, C, K = [int(x) for x in stdin.readline().rstrip().split()]\nif K-A <= 0:\n print(A, 'first')\nelif K-A > 0:\n if K-A-B <= 0:\n print(A, 'sec')\n else:\n print(int(A+(K-A-B)*-1), 'third')", 'from sys import stdin\nA, B, C, K = [int(x) for x in stdin.readline().rstrip().split()]\nif K-A <= 0:\n print(K)\nelif K-A > 0:\n if K-A-B <= 0:\n print(A)\n else:\n print(int(A+(K-A-B)*-1))\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s753204186', 's794104115', 's883834128', 's820666793']
[9196.0, 9156.0, 9196.0, 9184.0]
[22.0, 2206.0, 24.0, 19.0]
[232, 574, 231, 206]
p02682
u949210009
2,000
1,048,576
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?
['A,B,C,K = map(int,input().split())\nanswer = 0\nif K <= A:\n print(K)\nelif K > A:\n answer = A\n K = K - A\nif K <= B and K > 0 :\n print(answer)\nelif K > B:\n K = K - B\nif K <= C and K > 0:\n answer = answer - K\n print(answer)', 'A,B,C,K = map(int,input().split())\nanswer = 0\nif K <= A:\n print(K)\nelif K > A:\n answer = A\n K = K - A\nif K <= B , K > 0 :\n print(answer)\nelif K > B:\n K = K - B\nif K <= C,K > 0:\n answer = answer - K\n print(answer)', 'A,B,C,K = map(int,input().split())\nanswer = 0\nif K <= A:\n print(K)\n K = 0\nelif K > A:\n answer = A\n K = K - A\nif K <= B and K > 0 :\n print(answer)\n K = 0\nelif K > B:\n K = K - B\nif K <= C and K > 0:\n answer = answer - K\n print(answer)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s872825063', 's958463980', 's767997775']
[9132.0, 9048.0, 9204.0]
[22.0, 20.0, 21.0]
[239, 233, 259]
p02682
u952968889
2,000
1,048,576
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?
['a, b, c, k = map(int, input().split())\nnum = a\nk -= a\n\nif k>0:\n k-=b\n if k>0:\n print(num-k)\n exit()\n else:\n print(num)\n\nprint(num)', 'a, b, c, k = map(int, input().split())\nnum = 0\n\nif k-a>0:\n num += a\n k-=a\n if k-b>0:\n k -= b\n print(num-k)\n else:\n print(num)\nelse:\n print(k)']
['Wrong Answer', 'Accepted']
['s276569580', 's061279845']
[9180.0, 9116.0]
[19.0, 21.0]
[160, 177]
p02682
u953379577
2,000
1,048,576
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?
['if k<=a:\n print(k)\nelse:\n x = k-a\n if x<=b:\n print(a)\n else:\n print(a-(x-b))', '\na,b,c,k = map(int,input().split())\n\nif k<=a:\n print(k)\nelse:\n x = k-a\n if x<=b:\n print(a)\n else:\n print(a-(x-b))']
['Runtime Error', 'Accepted']
['s754420500', 's625874150']
[9088.0, 9196.0]
[21.0, 21.0]
[102, 139]
p02682
u953794676
2,000
1,048,576
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?
['# abc167 b\na, b, c, k = [int(i) for i in input().split()]\nans = 0\nif k < a:\n ans = 0\nelif k < a + b:\n ans = a\nelse:\n ans = a - (k-(a+b))', '# abc167 b\na, b, c, k = [int(i) for i in input().split()]\nans = 0\nif k <= a:\n ans = k\nelif k <= a + b:\n ans = a\nelse:\n ans = a - (k-(a+b))\nprint(ans)']
['Wrong Answer', 'Accepted']
['s644558573', 's454995045']
[9164.0, 9100.0]
[23.0, 23.0]
[145, 158]
p02682
u957957759
2,000
1,048,576
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?
['a,b,c,x=map(int,input().split())\n \nif:\n print(x)\nelif x<a+b:\n print(int(a))\nelse:\n print(int(2*a+b-x))', 'a,b,c,x=map(int,input().split())\n \nif x<a:\n print(x)\nelif x<a+b:\n print(a)\nelse:\n print(2*a+b-x)']
['Runtime Error', 'Accepted']
['s572043595', 's830498926']
[9000.0, 9120.0]
[21.0, 21.0]
[105, 99]
p02682
u962765087
2,000
1,048,576
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?
['S = input()\nT = input()\n\nif(S==T[0:len(S)]):\n print(Yes)\n else:\n print(No)\n\t\n\n', 'A, B, C, K = map(int, input().split())\nif((K-A)>0):\n Y = K-A\nelse:\n print(K)\n exit()\nif((Y-B)>0):\n Z = Y-B\nelse:\n Z = 0\n\nX = A + 0 * Y + (-1) * Z\nprint(X)\n\n\n\n\n\n\n\n\n\n\n\n\t\n\n']
['Runtime Error', 'Accepted']
['s769919753', 's859546484']
[9016.0, 9076.0]
[23.0, 29.0]
[82, 184]
p02682
u964521959
2,000
1,048,576
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?
['A, B,C,K = map(int, input().split())\n\nans = 0\n\nfor i in range(A):\n if(K>0):\n ans = ans + 1\n K = K-1\nfor i in range(B):\n if(K>0):\n ans = ans \n K = K-1\nfor i in range(C):\n if(K>0):\n ans = ans - 1\n K = K-1', 'A, B,C,K = map(int, input().split())\nif(K<A):\n print(K)\nelif(K>A+B):\n print(A - (K-A-B))\nelse:\n print(A)']
['Wrong Answer', 'Accepted']
['s112963163', 's457413478']
[9032.0, 9016.0]
[2205.0, 20.0]
[223, 107]
p02682
u965482124
2,000
1,048,576
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?
['a, b, c , k = map(int, input().split())\nif k <=a:\n print(k)\nif k <=(a+b):\n print(a)\nif k < a+b+c:\n print(a-(k-(a+b)))\n', 'a, b, c , k = map(int, input().split())\nif k <=a:\n print(k)\nif k <=(a+b):\n print(a)\nif k <= a+b+c:\n print(a-(k-(a+b)))\n', 'a, b, c , k = map(int, input().split())\nif k <=a:\n print(k)\nif k <=(a+b):\n print(a)\nif k < a+b+c:\n print(a-c)\n ', 'def main(a, b,c,k):\n\n m = 0\n if k <=a:\n m = k\n elif k <=(a+b):\n m = a\n elif k <= a+b+c:\n m = (a-(k-(a+b)))\n return m\na, b, c , k = map(int, input().split())\nprint(main(a,b,c,k))']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s048179451', 's057319632', 's523497893', 's158172181']
[9044.0, 9108.0, 9012.0, 9136.0]
[30.0, 29.0, 24.0, 29.0]
[127, 128, 123, 213]
p02682
u975719989
2,000
1,048,576
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?
['a,b,c,k = map(int,input().split())\nif a >= k:\n\tprint(k)\nelif a+b >=k:\n\tprint(k)\nelse:\n print(a*1+b*0 +(k-a-b)*(-1))\n \n\n', 'a,b,c,k = map(int,input().split())\nxa = min(a,k)\nk-=xa\nxb=min(b,k)\nk-=xb\nxc=k\nprint(xa-xc)\n \n\n']
['Wrong Answer', 'Accepted']
['s898018648', 's322046767']
[9004.0, 9160.0]
[23.0, 22.0]
[125, 97]
p02682
u982030663
2,000
1,048,576
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?
['A, B, C, K = map(int, input.split(" "))\nif K <= A:\n print(K)\nelse:\n K = K - A\n if K <= B:\n print(A)\n else:\n K = K - B\n print(A - K)\n', 'A, B, C, K = map(int, input().split(" "))\nif K <= A:\n print(K)\nelse:\n K = K - A\n if K <= B:\n print(A)\n else:\n K = K - B\n print(A - K)\n']
['Runtime Error', 'Accepted']
['s825415458', 's295802485']
[9096.0, 9164.0]
[23.0, 22.0]
[165, 167]
p02682
u984592063
2,000
1,048,576
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?
['a = input()\nb = input()\nc = input()\nk = input()\n\nif(k<a):\n print(k)\nelif(k>a and k<a+b):\n print(a)\nelif(k>a+b and k<a+b+c):\n print(a-(k-(a+b)))\n', 'a, b, c, k = map(int, input().split())\n\nif(k<=a):\n print(k)\nelif(k>a and k<=a+b):\n print(a)\nelse:\n print(a-(k-(a+b)))\n']
['Runtime Error', 'Accepted']
['s344037098', 's991435678']
[9048.0, 9172.0]
[24.0, 22.0]
[153, 127]
p02682
u987549444
2,000
1,048,576
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?
['from sys import stdin\n\na=stdin.readline().split()\nA=int(a[0]) #1\nB=int(a[1]) #0\nC=int(a[2]) #-1\nK=int(a[3])\n\nif K<=A:\n print(K)\nelif K<A<=A+B:\n print(A)\nelse:\n print(2*(A+B)-K)', 'from sys import stdin\n \na=stdin.readline().split()\nA=int(a[0]) #1\nB=int(a[1]) #0\nC=int(a[2]) #-1\nK=int(a[3])\n \nif K<=A:\n print(K)\nelif K<A<=A+B:\n print(A)\nelse:\n print(2*A+B-K)']
['Wrong Answer', 'Accepted']
['s644056042', 's085581688']
[9160.0, 9192.0]
[24.0, 24.0]
[179, 179]
p02682
u988191897
2,000
1,048,576
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?
['A,B,C,K = map(int,input().split())\nif A + B >= K:\n\tprint(K)\nelse:\n\tprint(A-(K-(A+B)))', 'A,B,C,K = map(int,input().split())\nif A + B >= K:\n\tprint(max(K,A))\nelse:\n\tprint(A-(K-(A+B)))', 'A,B,C,K = map(int,input().split())\nif A + B >= K:\n\tprint(max(K.A))\nelse:\n\tprint(A-(K-(A+B)))', 'A,B,C,K = map(int,input().split())\nif A + B >= K:\n\tprint(min(K,A))\nelse:\n\tprint(A-(K-(A+B)))']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s375255300', 's860529535', 's927821456', 's924713600']
[9192.0, 9060.0, 9168.0, 9164.0]
[23.0, 22.0, 23.0, 24.0]
[85, 92, 92, 92]
p02682
u995163736
2,000
1,048,576
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?
['A = list(map(int, input().split()))\n\nif A[0]+A[1]+A[2]>=A[3]:\n if A[3]-A[0]-A[1]>A[2]:\n \tprint(A[0]-(A[3]-A[0]-A[1]))\n else:\n print(A[0]-A[2])\nelse:\n print(A[0]-A[2])', 'A = list(map(int, input().split())) \n\nans=0\nif A[0]<A[3]:\n ans = A[0]\nelse:\n ans = A[3]\n print(ans)\n \nprint(ans-(A[3]-A[0]-A[1])', 'A = list(map(int, input().split()))\n \nif A[0]>=A[3]:\n print(A[3])\nelse:\n if A[0]+A[1]>=A[3]:\n print(A[0])\n else:\n print(A[0]-A[3]+A[0]+A[1])']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s302885057', 's689338286', 's864708179']
[9224.0, 9040.0, 9176.0]
[22.0, 23.0, 20.0]
[173, 132, 149]
p02682
u996996256
2,000
1,048,576
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?
['l = map(int, input().split())\nlists = [1]*l[0] + [0]*l[1] + [-1]*l[2]\nsum = 0\nfor i in range(l[3]):\n sum += lists[i]\nprint(sum)', 'a, b, c, k = map(int, input().split())\nprint(a+b if a+b>=k else a-(k-a-b))', 'a, b, c, k = map(int, input().split())\nprint(a if a>=k else a-c)', 'a, b, c, k = map(int, input().split())\nprint(min(a, k, a-(k-a-b))', 'a, b, c, k = map(int, input().split())\nprint(min(a, k, a*2+b-k))']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s300165140', 's311246853', 's688396171', 's986983744', 's844934079']
[8892.0, 9144.0, 9008.0, 8900.0, 9120.0]
[21.0, 19.0, 23.0, 21.0, 21.0]
[130, 74, 64, 65, 64]
p02682
u997648604
2,000
1,048,576
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?
['import math\nsys.setrecursionlimit(10**9)\n\ndef main():\n A,B,C,K = map(int,input().split())\n\n if K<= A:\n print(K)\n elif K<=B:\n print(A)\n else:\n print(2*A+B-K)\n\nif __name__ == "__main__":\n main()', 'import sys\nimport math\nsys.setrecursionlimit(10**9)\n\ndef main():\n A,B,C,K = map(int,input().split())\n\n if K<= A:\n print(K)\n elif K<=B:\n print(A)\n else:\n print(2*A+B-K)\n\nif __name__ == "__main__":\n main()\n']
['Runtime Error', 'Accepted']
['s426112888', 's387674809']
[9104.0, 9196.0]
[20.0, 22.0]
[226, 238]
p02682
u998082063
2,000
1,048,576
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?
['A, B, C, K = inpl()\nif A >= K:\n print(K)\n exit()\nif A+B >= K:\n print(A)\n exit()\nprint(A-(K-A-B))', "from collections import defaultdict, deque\nimport sys\nimport heapq\nimport bisect\nimport itertools\nimport queue\nimport copy\nimport time\nsys.setrecursionlimit(10**8)\nINF = float('inf')\nmod = 10**9+7\neps = 10**-7\n\ndef inp(): return int(sys.stdin.readline())\n\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\n\ndef inpl_str(): return list(sys.stdin.readline().split())\n\nA, B, C, K = inpl()\nif A >= K:\n print(K)\n exit()\nif A+B >= K:\n print(A)\n exit()\n\nprint(A - (K-A-B))"]
['Runtime Error', 'Accepted']
['s020204130', 's636015540']
[9060.0, 10048.0]
[20.0, 26.0]
[108, 491]
p02683
u017624958
2,000
1,048,576
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.
["N, M, X = list(map(int, input().split()))\nCA = [list(map(int, input().split())) for i in range(N)]\n# print(N, M, X)\n# print(CA)\n\ndef can_reach(M, CA, X):\n understandig_list = [0] * M\n for CAi in CA:\n for j in range(1, len(CAi)):\n understandig_list[j - 1] += CAi[j] \n\n can = all([understandig >= X for understandig in understandig_list])\n\n return can\n\n\nif not can_reach(M, CA, X):\n print('-1')\n exit(0)\n\nprint(0)\n", 'import itertools\n\n\nN, M, X = list(map(int, input().split()))\nCA = [list(map(int, input().split())) for i in range(N)]\n# print(N, M, X)\n# print(CA)\n\nINF = 10 ** 5 * 12 + 1\nmin_amount = INF\nfor i in range(1, N + 1):\n combinations = itertools.combinations(range(N), i)\n\n for combination in combinations:\n understanding_list = [0] * M\n amount = 0\n for i in combination:\n for j in range(1, len(CA[i])):\n understanding_list[j - 1] += CA[i][j]\n amount += CA[i][0]\n\n \n is_reached = all([understanding >= X for understanding in understanding_list])\n if not is_reached: continue\n\n min_amount = min(amount, min_amount)\n\nanswer = -1 if min_amount == INF else min_amount\n\nprint(answer)\n']
['Wrong Answer', 'Accepted']
['s557458445', 's003739456']
[9200.0, 9228.0]
[23.0, 81.0]
[448, 792]
p02683
u020472025
2,000
1,048,576
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.
["import numpy as np\n\nN, M, X = map(int, input().split())\n\nALL = np.zeros((1, M+1))\nfor n in range(N):\n CA = np.array([ int(i) for i in input().split() ])\n ALL = np.vstack([ALL, CA])\n\nA = ALL.sum(axis=0)\ncost =12*10**5+1\n#ALL = np.sort(ALL, axis=0)\n\nfor n in range(2**N):\n a = str(bin(n))[2:]\n b = N-len(a)\n c = np.array(list('0'*b+a)).astype('bool')\n #print(c)\n ALL2 = ALL[1:]\n check = ALL2[c].sum(axis=0)\n \n if (check[1:] < X).sum() < 1:\n if cost > check[0]:\n cost = check[0]\n\n\nif cost == 2**100:\n cost = -1\nprint(cost) ", "import numpy as np\n\nN, M, X = map(int, input().split())\n\nALL = np.zeros((1, M+1))\nfor n in range(N):\n CA = np.array([ int(i) for i in input().split() ])\n ALL = np.vstack([ALL, CA])\n\nA = ALL.sum(axis=0)\ncost =2**100\n#ALL = np.sort(ALL, axis=0)\n\nfor n in range(2**N):\n a = str(bin(n))[2:]\n b = N-len(a)\n c = np.array(list('0'*b+a)).astype('bool')\n #print(c)\n ALL2 = ALL[1:]\n check = ALL2[c].sum(axis=0)\n \n if (check[1:] < X).sum() < 1:\n if cost > check[0]:\n cost = check[0]\n\n\nif cost == 2**100:\n cost = -1\nprint(cost) ", "import numpy as np\n\nN, M, X = map(int, input().split())\n\nALL = np.zeros((1, M+1))\nfor n in range(N):\n CA = np.array([ int(i) for i in input().split() ])\n ALL = np.vstack([ALL, CA])\n\nA = ALL.sum(axis=0)\ncost =99999999999999\n#ALL = np.sort(ALL, axis=0)\n\n\nif (A[1:] < X).sum() > 0:\n print(-1)\nelse:\n for n in range(2**N):\n a = str(bin(n))[2:]\n b = N-len(a)\n c = np.array(list('0'*b+a)).astype('bool')\n #print(c)\n ALL2 = ALL[1:]\n check = ALL2[c].sum(axis=0)\n\n #print(check[0])\n # print(check[1:])\n if (check[1:] < X).sum() == 0:\n if cost >= check[0]:\n cost = check[0]\n\n print(cost)", "import numpy as np\n\nN, M, X = map(int, input().split())\n\nALL = np.zeros((1, M+1))\nfor n in range(N):\n CA = np.array([ int(i) for i in input().split() ])\n ALL = np.vstack([ALL, CA])\n\nA = ALL.sum(axis=0)\ncost =2**100\n#ALL = np.sort(ALL, axis=0)\n\n\nif (A[1:] < X).sum() > 0:\n print(-1)\nelse:\n for n in range(2**N):\n a = str(bin(n))[2:]\n b = N-len(a)\n c = np.array(list('0'*b+a)).astype('bool')\n #print(c)\n ALL2 = ALL[1:]\n check = ALL2[c].sum(axis=0)\n \n if (check[1:] < X).sum() == 0:\n if cost > check[0]:\n cost = check[0]\n\n print(cost) ", "import numpy as np\n\nN, M, X = map(int, input().split())\n\nALL = np.zeros((1, M+1))\nfor n in range(N):\n ALL = np.vstack([\n \t\t\t ALL, \n np.array([ int(i) for i in input().split() ])\n ])\n\ncost =12*10**5+1\nfor n in range(2**N):\n a = str(bin(n))[2:]\n b = N-len(a)\n c = np.array(list('0'*b+a)).astype('bool')\n #print(c)\n ALL2 = ALL[1:]\n check = ALL2[c].sum(axis=0)\n \n if (check[1:] < X).sum() < 1:\n if cost > check[0]:\n cost = check[0]\n\n\nif cost == 12*10**5+1:\n cost = -1\nprint(cost) \n\nprint(ALL)", 'import numpy as np\nimport itertools\n\nN, M, X = map(int, input().split())\n\nall_df = np.zeros((1,M+1))\nfor n in range(N):\n A = [int(i) for i in input().split()]\n all_df = np.vstack([all_df, np.array(A).reshape(1,-1)])\n\nall_df = all_df[1:]\n\nnow_cost = 10**9\nfor bins in itertools.product([0,1], repeat=N):\n prod = all_df[np.array(bins).astype(bool)].sum(axis=0)\n #print(prod)\n if (X > prod[1:]).sum() > 0:\n pass\n else:\n if prod[0] < now_cost:\n now_cost = prod[0]\n\nif now_cost == 10**9:\n print(-1)\nelse:\n print(int(now_cost))']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s085240999', 's162869612', 's334567263', 's496149360', 's648623141', 's757440405']
[27348.0, 27352.0, 27324.0, 27352.0, 27392.0, 27200.0]
[182.0, 182.0, 175.0, 176.0, 183.0, 159.0]
[561, 557, 624, 575, 565, 540]
p02683
u021548497
2,000
1,048,576
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.
['n, m, x = map(int, input().split())\nbooks = [0]*n\nfor i in range(n):\n books[i] = [int(x) for x in input().split()]\n\nans = 10**9\nfor i in range(2**n):\n cost = 0\n point = [0]*m\n for j in range(n):\n if (i>>j)&1:\n for k in range(1, m+1):\n point[k-1] += books[j][k]\n flag = True\n for j in range(m):n, m, x = map(int, input().split())\nbooks = [0]*n\nfor i in range(n):\n books[i] = [int(x) for x in input().split()]\n\nans = 10**9\nfor i in range(2**n):\n cost = 0\n point = [0]*m\n for j in range(n):\n if (i>>j)&1:\n cost += books[j][0]\n for k in range(1, m+1):\n point[k-1] += books[j][k]\n flag = True\n for j in range(m):\n if point[j] < x:\n flag = False\n if flag and ans > cost:\n ans = cost\n\nprint(ans if ans != 10**9 else -1)\n if point[j] < x:\n flag = False\n if flag and ans > cost:\n ans = cost\n\nprint(ans if ans != 10**9 else -1)', 'n, m, x = map(int, input().split())\nbooks = [0]*n\nfor i in range(n):\n books[i] = [int(x) for x in input().split()]\n\nans = 10**9\nfor i in range(2**n):\n cost = 0\n point = [0]*m\n for j in range(n):\n if (i>>j)&1:\n cost += books[j][0]\n for k in range(1, m+1):\n point[k-1] += books[j][k]\n flag = True\n for j in range(m):\n if point[j] < x:\n flag = False\n if flag and ans > cost:\n ans = cost\n\nprint(ans if ans != 10**9 else -1)']
['Runtime Error', 'Accepted']
['s114168002', 's360287713']
[9136.0, 9116.0]
[22.0, 91.0]
[888, 457]
p02683
u029021990
2,000
1,048,576
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.
['import numpy as np\n\nN,M,X = map(int, input().split())\n\na = np.zeros((N,M+1))\n\nfor i in range(N):\n \n a[i] = [int(x) for x in input().split()]\n\nb = np.zeros(N)\nc = np.zeros(M+1)\nmin_cost = 9999999999999999\n\nfor i in range(2**N):\n ii = i\n for j in range(N):\n b[j] = ii % 2\n ii = ii // 2\n c = np.zeros(M+1)\n flg = "ok"\n for k in range(M+1):\n for j in range(N):\n c[k] += a[j,k] * b[j]\n if k > 0 and c[k] < X:\n flg = "ng"\n continue\n if flg == "ok":\n min_cost = min(min_cost,c[0])\n\nif min_cost == 9999999999999999:\n print(-1)\nelse:\n print(min_cost)\n\n\n ', 'import numpy as np\n\nN,M,X = map(int, input().split())\n\na = np.zeros((N,M+1))\n\nfor i in range(N):\n \n a[i] = [int(x) for x in input().split()]\n\nb = np.zeros(N)\nc = np.zeros(M+1)\nmin_cost = 9999999999999999\n\nfor i in range(2**N):\n ii = i\n for j in range(N):\n b[j] = ii % 2\n ii = ii // 2\n c = np.zeros(M+1)\n flg = "ok"\n for k in range(M+1):\n for j in range(N):\n c[k] += a[j,k] * b[j]\n if k > 0 and c[k] < X:\n flg = "ng"\n continue\n if flg == "ok":\n min_cost = min(min_cost,c[0])\n\nif min_cost == 9999999999999999:\n print(-1)\nelse:\n print(int(min_cost))\n\n\n ']
['Wrong Answer', 'Accepted']
['s561057417', 's204513416']
[27008.0, 27184.0]
[549.0, 576.0]
[745, 750]
p02683
u033360495
2,000
1,048,576
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.
['N, M, X = map(int,input().split())\nA=[]\nfor i in range(N):\n A.append(list(map(int, input().split())))\n \npr=10**9\nfor s in range(2**N):\n x_m = [0]*13\n for i in range(N):\n b = (s >> i) & 1\n if b == 1:\n pr_s += A[i][0]\n for j in range(M+1):\n x_m[j] += A[i][j]\n\n xOk = True\n for j in range(1,M+1):\n if x_m[j] < X:\n xOk = False\n \n if xOk == True:\n pr = min(pr, x_m[0])\n\nif pr<10**9:\n print(pr)\nelse:\n print(-1)', 'N, M, X = map(int,input().split())\nA=[]\nfor i in range(N):\n A.append(list(map(int, input().split())))\n \npr=10**9\nfor s in range(2**N):\n x_m = [0]*13\n for i in range(N):\n b = (s >> i) & 1\n if b == 1:\n pr_s += A[i][0]\n for j in range(M+1):\n x_m[j] += A[i][j]\n \n xOk = True\n for j in range(1,M+1):\n if x_m[j] < X:\n xOk = False\n \n if xOk == True:\n pr = min(pr, x_m[0])\n \nif pr<10**9:\n print(pr)\nelse:\n print(-1)', 'N, M, X = map(int,input().split())\nA=[]\nfor i in range(N):\n A.append(list(map(int, input().split())))\n \npr=10**9\nfor s in range(2**N):\n x_m = [0]*13\n for i in range(N):\n b = (s >> i) & 1\n if b == 1:\n for j in range(M+1):\n x_m[j] += A[i][j]\n \n xOk = True\n for j in range(1,M+1):\n if x_m[j] < X:\n xOk = False\n \n if xOk == True:\n pr = min(pr, x_m[0])\n \nif pr<10**9:\n print(pr)\nelse:\n print(-1)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s638041964', 's949417891', 's750175943']
[9240.0, 9240.0, 9128.0]
[20.0, 22.0, 91.0]
[511, 513, 485]
p02683
u036914910
2,000
1,048,576
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.
['import itertools\nN,M,X = map(int,input().split())\nA = [0]*M\nC = []\nZ = []\ncz = []\nb = 0\nfor i in range(N) :\n C.append(list(map(int,input().split())))\n\nfor i in range(1,N+1) :\n c = list(itertools.combinations(C,i))\n print(c)\n for j in range(len(c)) :\n A=[0]*M\n cj = c[j]\n for k in range(i) :\n ck = cj[k]\n for l in range(M) :\n A[l]+= ck[l] \n for m in range(1,M) :\n if A[m] < X :\n break\n cz.append(A[0])\n\nif len(cz) == 0 :\n print(-1)\nelse :\n print(min(cz))', "import numpy\nN,M,X = map(int,input().split())\nA = numpy.array([[int(i) for i in input().split()] for _ in range(N)])\nans = 10**8\nfor i in range(2**N) :\n i = format(i,'b').zfill(N)\n check = numpy.array([0]*(M+1))\n for j in range(N) :\n if i[j] == '0' :\n continue\n check += A[j][0:]\n if all (check[m] >= X for m in range(1,M+1)) :\n ans = min(ans,check[0])\n\nif ans == 10**8 :\n print(-1)\nelse :\n print(ans)"]
['Wrong Answer', 'Accepted']
['s632096953', 's069226247']
[10656.0, 27236.0]
[108.0, 176.0]
[580, 452]
p02683
u048800107
2,000
1,048,576
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.
['\n\nN,M,X = map(int,input().split())\nitems = [list(map(int,input().split())) for _ in range(N)]\nans = -1\nfor i in range(1 << N):\n total = [0]*(M+1)\n for j in range(N): \n if ((i >> j) & 1): \n h = [x + y for (x, y) in zip(total, items[j])]\n # print(total)\n if all( k >= X for k in h[1:]) == True:\n if ans == -1:\n ans = h[0]\n else:\n ans = min(ans,total[0]) \nprint(ans)\n\n', '\n\nN,M,X = map(int,input().split())\nitems = [list(map(int,input().split())) for _ in range(N)]\nans = -1\nfor i in range(1 << N):\n total = [0]*(M+1)\n for j in range(N): \n if ((i >> j) & 1): \n total = [x + y for (x, y) in zip(total, items[j])]\n # print(total)\n if all( k >= X for k in total[1:]) == True:\n if ans == -1:\n ans = total[0]\n else:\n ans = min(ans,total[0]) \nprint(ans)\n\n']
['Runtime Error', 'Accepted']
['s358022185', 's500829616']
[9200.0, 9136.0]
[23.0, 57.0]
[518, 530]
p02683
u050706842
2,000
1,048,576
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.
['import numpy as np\n\nN, M, X = list(map(int, input().split()))\n\nCA = []\nfor i in range(N):\n s = input()\n CA.append(np.fromstring(s, np.int16, sep=" "))\n\nCA = np.asarray(CA)\nC = CA[:, :1]\nA = CA[:, 1:]\n\ndef loop(i, x, total):\n if i == N:\n if (x >= X).all():\n return total\n else:\n return np.inf\n\n return min(loop(i+1, x, total), loop(i+1, x+A[i], total+C[i]))\n\nans = loop(0, np.zeros_like(A[0]), 0)\nif ans == np.inf:\n print(-1)\nelse:\n print(ans)', 'import numpy as np\n\nN, M, X = list(map(int, input().split()))\n\nCA = []\nfor i in range(N):\n s = input()\n CA.append(np.fromstring(s, np.int64, sep=" "))\n\nCA = np.asarray(CA)\nC = CA[:, :1]\nA = CA[:, 1:]\n\ndef loop(i, x, total):\n if i == N:\n if (x >= X).all():\n return total\n else:\n return np.inf\n\n return min(loop(i+1, x, total), loop(i+1, x+A[i], total+C[i]))\n\nans = loop(0, np.zeros_like(A[0]), 0)\nif ans == np.inf:\n print(-1)\nelse:\n print(ans)', 'import numpy as np\n\nN, M, X = list(map(int, input().split()))\n\nCA = []\nfor i in range(N):\n s = input()\n CA.append(np.fromstring(s, np.int64, sep=" "))\n\nCA = np.asarray(CA)\nC = CA[:, 0]\nA = CA[:, 1:]\n\ndef loop(i, x, total):\n if i == N:\n if (x >= X).all():\n return total\n else:\n return np.inf\n\n return min(\n loop(i+1, x, total),\n loop(i+1, (x+A[i]).clip(0, X), total+C[i])\n )\n\nans = loop(0, np.zeros_like(A[0]), 0)\nif ans == np.inf:\n print(-1)\nelse:\n print(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s224089817', 's773089352', 's306869837']
[27352.0, 27372.0, 27140.0]
[126.0, 133.0, 169.0]
[496, 496, 530]
p02683
u050708958
2,000
1,048,576
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.
['n, m, x = [*map(int, input().split())]\nk = []\nans = 10 ** 6\nfor i in range(n):\n c, *a = [*map(int, input().split())]\n s += c\n k.append([c, *a])\n\nfor i in range(2 ** n):\n cost = 0\n skills = [0] * m\n for j in range(n):\n if ((i >> j) & 1):\n cost += k[j][0]\n for s, t in enumerate(k[j][1:]):\n skills[s] += t\n if all(map(lambda skill: skill >= x, skills)):\n ans = min(ans, cost)\nprint(-1 if ans == 10 ** 6 else ans)', 'n, m, x = [*map(int, input().split())]\nk = [[*map(int, input().split())] for _ in range(n)]\nans = 10 ** 9\n\nfor i in range(2 ** n):\n cost = 0\n skills = [0] * m\n for j in range(n):\n if ((i >> j) & 1):\n cost += k[j][0]\n for s, t in enumerate(k[j][1:]):\n skills[s] += t\n if all(map(lambda skill: skill >= x, skills)):\n ans = min(ans, cost)\nprint(-1 if ans == 10 ** 9 else ans)\n']
['Runtime Error', 'Accepted']
['s121680086', 's935251741']
[9232.0, 9120.0]
[28.0, 104.0]
[498, 452]
p02683
u052244548
2,000
1,048,576
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.
['N, M, X = map(int,input().split())\na=[]\nb=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]\nc=[]\nfor i in range(N):\n a.append(input().split())\n c.append(0)\n\ncheck=0\nans=-1\nfor i in range(1,(2**N)-1):\n b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]\n check=0\n for j in range(N):\n if 0x01 & (i >> j):\n for n in range(M+1):\n b[n] = b[n] + int(a[j][n])\n for k in range(1,M):\n if b[k] < X:\n check=1\n break\n if check==0:\n #print(ans)\n if ans == -1 or ans > b[0]:\n ans = b[0]\nprint(ans)\n', 'N, M, X = map(int,input().split())\na=[]\nb=[0,0,0,0,0,0,0,0,0,0,0,0,0,0]\nc=[]\nfor i in range(N):\n a.append(input().split())\n c.append(0)\n\ncheck=0\nans=-1\nfor i in range(2**N):\n b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0]\n for j in range(N):\n if 0x01 & (i >> j):\n for n in range(M+1):\n b[n] = b[n] + int(a[j][n])\n\n check=0\n print(b)\n for k in range(1,M):\n if b[k] < X:\n check=1\n\n if check==0:\n if ans == -1 or ans > b[0]:\n ans = b[0]\n\nprint(ans)\n', 'N, M, X = map(int,input().split())\na=[]\nb=[0,0,0,0,0,0,0,0,0,0,0,0,0,0]\nc=[]\nfor i in range(N):\n a.append(input().split())\n c.append(0)\n\ncheck=0\nans=-1\nfor i in range(2**N):\n b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0]\n for j in range(N):\n if 0x01 & (i >> j):\n for n in range(M+1):\n b[n] = b[n] + int(a[j][n])\n\n check=0\n print(b)\n for k in range(1,M):\n if b[k] < X:\n check=1\n\n if check==0:\n if ans == -1 or ans > b[0]:\n ans = b[0]\n\nprint(ans)\n', 'N, M, X = map(int,input().split())\na=[]\nb=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]\n\nfor i in range(N):\n a.append(input().split())\n\ncheck=0\nans=-1\nfor i in range(1,pow(2,N)):\n b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]\n check=0\n for j in range(N):\n if 0x01 & (i >> j):\n for n in range(M+1):\n b[n] = b[n] + int(a[j][n])\n for k in range(1,M+1):\n if b[k] < X:\n check=1\n if check==0:\n if ans == -1 or ans > b[0]:\n ans = b[0]\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s181501367', 's338448568', 's888820390', 's171235973']
[9264.0, 9196.0, 9220.0, 9268.0]
[160.0, 271.0, 271.0, 129.0]
[584, 556, 556, 511]
p02683
u054274920
2,000
1,048,576
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.
['N,M,X = map(int,input().split())\nC=[0 for i in range(N)]\nA=[[] for i in range(N)]\nmin_cost=10000000000\nfor i in range(N):\n C[i],*A[i]=map(int,input().split())\nfor i in range(1<<N):\n L=[0 for i in range(M)]\n cost=0\n for j in range(N):\n if 1&(i>>j):\n for k in range(M):\n L[k]+=A[j][k]\n cost+=C[j]\n if min(L)>=X:\n min_cost=min(min_cost,cost)\nif min_cost=10000000000:\n print(-1)\nelse:\n print(min_cost)', 'N,M,X = map(int,input().split())\nC=[0 for i in range(N)]\nA=[[] for i in range(N)]\nmin_cost=10000000000\nfor i in range(N):\n C[i],*A[i]=map(int,input().split())\nfor i in range(1<<N):\n L=[0 for i in range(M)]\n cost=0\n for j in range(N):\n if 1&(i>>j):\n for k in range(M):\n L[k]+=A[j][k]\n cost+=C[j]\n if min(L)>=X:\n min_cost=min(min_cost,cost)\nif min_cost==10000000000:\n print(-1)\nelse:\n print(min_cost)']
['Runtime Error', 'Accepted']
['s735159722', 's163095257']
[8992.0, 9240.0]
[23.0, 85.0]
[463, 464]
p02683
u059487235
2,000
1,048,576
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.
["\nn, m, x = map(int, input().split())\nca = [list(map(int, input().split())) for _ in range(n)]\n\nans = -1\nfor i in range(2**n):\n li = [0]*(m+1)\n print('==========')\n for j in range(n):\n print('i = ', i)\n print('j = ', j)\n print('(i >> j) = ', (i >> j))\n print('((i >> j) & 1) = ', ((i >> j) & 1))\n if ((i >> j) & 1):\n for k in range(m+1):\n li[k] += ca[j][k]\n print('li = ', li)\n for j in range(1, m+1):\n if li[j] < x:\n break\n else:\n if ans == -1:\n ans = li[0]\n else:\n if ans > li[0]:\n ans = li[0]\nprint(ans)\n", "\nn, m, x = map(int, input().split())\nca = [list(map(int, input().split())) for _ in range(n)]\n\nans = -1\nfor i in range(2**n):\n li = [0]*(m+1)\n \n for j in range(n):\n # print('i = ', i)\n # print('j = ', j)\n # print('(i >> j) = ', (i >> j))\n # print('((i >> j) & 1) = ', ((i >> j) & 1))\n if ((i >> j) & 1):\n for k in range(m+1):\n li[k] += ca[j][k]\n # print('li = ', li)\n for j in range(1, m+1):\n if li[j] < x:\n break\n else:\n if ans == -1:\n ans = li[0]\n else:\n if ans > li[0]:\n ans = li[0]\nprint(ans)\n"]
['Wrong Answer', 'Accepted']
['s127054090', 's525335022']
[10516.0, 9228.0]
[281.0, 85.0]
[678, 690]
p02683
u060736237
2,000
1,048,576
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.
['def main()\n n, m, x = map(int, input().split())\n ca = []\n for _ in range(n):\n ca.append(list(map(int, input().split())))\n result = 10**9\n for i in range(1, 2**n+1):\n work = 0\n j = 0\n temp = [0] * m\n for flag in bin(i)[2:].zfill(n):\n if flag == "1":\n work += ca[j][0]\n for k in range(1, m+1):\n temp[k-1] += ca[j][k]\n j += 1\n flag = True\n for t in temp:\n if t < x:\n flag = False\n break\n if flag:\n result = min(result, work)\n if result == 10**9:\n print(-1)\n else:\n print(result)\nmain()', 'def main():\n n, m, x = map(int, input().split())\n ca = []\n for _ in range(n):\n ca.append(list(map(int, input().split())))\n result = 10**9\n for i in range(1, 2**n+1):\n work = 0\n j = 0\n temp = [0] * m\n for flag in bin(i)[2:].zfill(n):\n if flag == "1":\n work += ca[j][0]\n for k in range(1, m+1):\n temp[k-1] += ca[j][k]\n j += 1\n flag = True\n for t in temp:\n if t < x:\n flag = False\n break\n if flag:\n result = min(result, work)\n if result == 10**9:\n print(-1)\n else:\n print(result)\nmain()']
['Runtime Error', 'Accepted']
['s527225584', 's193424512']
[8948.0, 9228.0]
[24.0, 63.0]
[696, 697]
p02683
u060793972
2,000
1,048,576
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.
['import itertools\nn,m,x=map(int,input().split())\nl=list()\nfor i in range(n):\n l.append(list(map(int,input().split())))\nfor i in range(1,n+1):\n for j in itertools.combinations(l,i):\n print(j)\n r=[0 for i in range(m)]\n for k in j:\n a=0\n p=0\n for i in range(1,m+1):\n r[i-1]+=k[i]\n a+=r[i-1]>=x\n if a==m:\n for c in j:\n p+=c[0]\n print(p)\n exit()\nprint(-1)\n', 'import itertools\nn,m,x=map(int,input().split())\nl=list()\nfor i in range(n):\n l.append(list(map(int,input().split())))\npp=list()\nfor i in range(1,n+1):\n for j in itertools.combinations(l,i):\n r=[0 for i in range(m)]\n for k in j:\n a=0\n p=0\n for i in range(1,m+1):\n r[i-1]+=k[i]\n a+=r[i-1]>=x\n if a==m:\n for c in j:\n p+=c[0]\n pp.append(p)\nif len(pp)==0:\n print(-1)\nelse:\n print(min(pp))\n']
['Wrong Answer', 'Accepted']
['s073144212', 's507623253']
[9308.0, 9584.0]
[129.0, 109.0]
[515, 533]
p02683
u062484507
2,000
1,048,576
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.
["import itertools\nimport sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nn, m, x = map(int, readline().split())\nc = [list(map(int, readline().split())) for _ in range(n)]\n\nans = 10 ** 9 + 7\nfor l in list(itertools.product([0, 1], repeat=n)):\n cart = [0] * (m + 1)\n for i, a in enumerate(l):\n if a == 1:\n array = c[i]\n cart = list(map(lambda x,y: x+y, cart, array))\n if min(cart[1::]) >= x:\n ans = min(ans, cart[0])\nprint(ans if ans != 10 ** 9 + 7 else '-1')", "import itertools\nimport sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nn, m, x = map(int, readline().split())\nc = [list(map(int, readline().split())) for _ in range(n)]\n\nans = 10 ** 9 + 7\nfor l in list(itertools.product([0, 1], repeat=n)):\n cart = [0] * (m + 1)\n for i in [i for i, a in enumerate(l) if a == 1]:\n array = c[i]\n cart = list(map(lambda x,y: x+y, cart, array))\n if min(cart[1::]) >= x:\n ans = min(ans, cart[0])\n \nprint(ans if ans != 10 ** 9 + 7 else '-1')"]
['Runtime Error', 'Accepted']
['s048079008', 's567980734']
[8996.0, 9540.0]
[21.0, 61.0]
[555, 568]
p02683
u068944955
2,000
1,048,576
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.
['import pandas as pd', 'import itertools\nN, M, X = map(int, input().split())\nC = []\nA = dict()\nfor i in range(N):\n CA = list(map(int, input().split()))\n C.append(CA[0])\n for j in range(1, M+1):\n if j in A:\n A[j].append(CA[j])\n else:\n A[j] = [CA[j]]\n\ncost = float("inf")\n\nfor i in range(1, N+1):\n for pm in itertools.combinations(list(range(1, N+1)), r=i):\n c = 0\n k = dict()\n for p in pm:\n c += C[p-1]\n\n for m in range(1, M+1):\n if m in k:\n k[m] += A[m][p - 1]\n else:\n k[m] = A[m][p - 1]\n\n if min(k.values()) >= X:\n cost = min(cost, c)\n\n\nif cost == float("inf"):\n print(-1)\nelse:\n print(cost)']
['Runtime Error', 'Accepted']
['s183563437', 's558439215']
[9108.0, 9148.0]
[24.0, 84.0]
[19, 751]
p02683
u072717685
2,000
1,048,576
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.
["from itertools import product\ndef main():\n n, m, x = map(int, input().split())\n books = []\n for _ in range(n):\n books.append(tuple(map(int, input().split())))\n\n books_set_all = []\n books_pattern = product((0, 1), repeat=n)\n for each_pattern in books_pattern:\n print(each_pattern)\n books_set = [0] * (m + 1)\n for i1 in range(n):\n if each_pattern[i1] == 1:\n for i2 in range(m + 1):\n books_set[i2] += books[i1][i2]\n books_set_all.append(books_set)\n price_all = []\n for ebs in books_set_all:\n price = ebs[0]\n ebs[0] = x\n if len([j for j in ebs if j >= x]) == m + 1:\n price_all.append(price)\n if len(price_all) > 0:\n print(min(price_all))\n else:\n print(-1)\n\nif __name__ == '__main__':\n main()", "from itertools import product\ndef main():\n n, m, x = map(int, input().split())\n books = []\n for _ in range(n):\n books.append(tuple(map(int, input().split())))\n\n books_set_all = []\n books_pattern = product((0, 1), repeat=n)\n for each_pattern in books_pattern:\n books_set = [0] * (m + 1)\n for i in each_pattern:\n if i:\n for i2 in range(m + 1):\n books_set[i2] += books[i][i2]\n books_set_all.append(books_set)\n price_all = []\n for ebs in books_set_all:\n price = ebs[0]\n ebs[0] = x\n if len([j for j in ebs if j >= x]) == m + 1:\n price_all.append(price)\n if len(price_all) > 0:\n print(min(price_all))\n else:\n print(-1)\n\nif __name__ == '__main__':\n main()\n", "import sys\nread = sys.stdin.read\nreadlines = sys.stdin.readlines\nimport numpy as np\ndef main():\n n, m, x = map(int, input().split())\n data = np.array(read().split(), np.int64)\n data = data.reshape(n, -1) \n cost_per_cost = data[:, 0] \n effect_per_book = data[:, 1:]\n\n costs = np.zeros(2**n, np.int64)\n \n ability = np.zeros((2**n, m), np.int64)\n for i in range(n):\n costs[1<<i:1<<(i+1)] = costs[:1<<i] + cost_per_cost[i]\n ability[1<<i:1<<(i+1)] = ability[:1<<i] + effect_per_book[i]\n ok = np.all(ability >= x, axis=1)\n res = costs[ok]\n if len(res) == 0:\n print(-1)\n else:\n print(res.min())\n\nif __name__ == '__main__':\n main()\n\n"]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s077806624', 's456771100', 's455014687']
[11184.0, 11340.0, 27656.0]
[71.0, 60.0, 118.0]
[846, 801, 829]
p02683
u073589005
2,000
1,048,576
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.
['import numpy as np \nimport itertools\n\nval = input()\nval = val.split(" ")\nval = [int(i) for i in val] \n\nI = np.zeros((val[0], val[1]+1))\n\nfor i in range(val[0]):\n val2 = input()\n val2 = val2.split(" ")\n val2 = [int(i) for i in val2] \n I[i] = val2\n\nseq = [i for i in range(val[0])] \n# print(seq)\n\nans = []\n\nfor i in range(val[0]):\n Comb = list(itertools.combinations(seq, i+1))\n # print(Comb)\n for j in Comb:\n Com_list = list(j)\n # print(Com_list)\n I_sum = [[I[k][l+1] for k in Com_list] for l in range(val[1])]\n # print(I_sum)\n I_sum_over_x = [sum(m) for m in I_sum if sum(m) >= val[2]]\n # print(\'I_sum_over_x=\', I_sum_over_x)\n if(len(I_sum_over_x) == val[1]):\n \n I_sum2 = [I[n][0] for n in list(j)]\n # print(I_sum2)\n # print(sum(I_sum2))\n ans.append(sum(I_sum2))\n\n# print(ans)\nif(len(ans) == 0):\n print(\'-1\')\nelse:\n print(min(ans))', 'import numpy as np \nimport itertools\n\nval = input()\nval = val.split(" ")\nval = [int(i) for i in val] \n\nI = np.zeros((val[0], val[1]+1))\n\nfor i in range(val[0]):\n val2 = input()\n val2 = val2.split(" ")\n val2 = [int(i) for i in val2] \n I[i] = val2\n\nseq = [i for i in range(val[0])] \n# print(seq)\n\nans = []\n\nfor i in range(val[0]):\n Comb = list(itertools.combinations(seq, i+1))\n print(Comb)\n for j in Comb:\n Com_list = list(j)\n # print(Com_list)\n I_sum = [[I[k][l+1] for k in Com_list] for l in range(val[1])]\n # print(I_sum)\n I_sum_over_x = [sum(m) for m in I_sum if sum(m) >= val[2]]\n # print(\'I_sum_over_x=\', I_sum_over_x)\n if(len(I_sum_over_x) == val[1]):\n \n I_sum2 = [I[n][0] for n in list(j)]\n # print(I_sum2)\n # print(sum(I_sum2))\n ans.append(sum(I_sum2))\n\n# print(ans)\nif(len(ans) == 0):\n print(\'-1\')\nelse:\n print(int(min(ans)))', 'import numpy as np \nimport itertools\n\nval = input()\nval = val.split(" ")\nval = [int(i) for i in val] \n\nI = np.zeros((val[0], val[1]+1))\n\nfor i in range(val[0]):\n val2 = input()\n val2 = val2.split(" ")\n val2 = [int(i) for i in val2] \n I[i] = val2\n\nseq = [i for i in range(val[0])] \n# print(seq)\n\nans = []\n\nfor i in range(val[0]):\n Comb = list(itertools.combinations(seq, i+1))\n print(Comb)\n for j in Comb:\n Com_list = list(j)\n # print(Com_list)\n I_sum = [[I[k][l+1] for k in Com_list] for l in range(val[1])]\n # print(I_sum)\n I_sum_over_x = [sum(m) for m in I_sum if sum(m) >= val[2]]\n # print(\'I_sum_over_x=\', I_sum_over_x)\n if(len(I_sum_over_x) == val[1]):\n \n I_sum2 = [I[n][0] for n in list(j)]\n # print(I_sum2)\n # print(sum(I_sum2))\n ans.append(sum(I_sum2))\n\n# print(ans)\nif(len(ans) == 0):\n print(\'-1\')\nelse:\n print(min(ans))\n', 'import numpy as np \nimport itertools\n\nval = input()\nval = val.split(" ")\nval = [int(i) for i in val] \n\nI = np.zeros((val[0], val[1]+1))\n\nfor i in range(val[0]):\n val2 = input()\n val2 = val2.split(" ")\n val2 = [int(i) for i in val2] \n I[i] = val2\n\nseq = [i for i in range(val[0])] \nprint(seq)\n\nfor i in range(val[0]):\n Comb = list(itertools.combinations(seq, i+1))\n # print(Comb)\n for j in Comb:\n Com_list = list(j)\n # print(Com_list)\n I_sum = [[I[k][l+1] for k in Com_list] for l in range(val[1])]\n print(I_sum)\n ans = [sum(i) for m in I_sum]\n print(\'ans=\', ans)\n \n # print(I[Com_list])\n', 'import numpy as np \nimport itertools\n\nval = input()\nval = val.split(" ")\nval = [int(i) for i in val] \n\nI = np.zeros((val[0], val[1]+1))\n\nfor i in range(val[0]):\n val2 = input()\n val2 = val2.split(" ")\n val2 = [int(i) for i in val2] \n I[i] = val2\n\nseq = [i for i in range(val[0])] \n# print(seq)\n\nans = []\n\nfor i in range(val[0]):\n Comb = list(itertools.combinations(seq, i+1))\n # print(Comb)\n for j in Comb:\n Com_list = list(j)\n # print(Com_list)\n I_sum = [[I[k][l+1] for k in Com_list] for l in range(val[1])]\n # print(I_sum)\n I_sum_over_x = [sum(m) for m in I_sum if sum(m) >= val[2]]\n # print(\'I_sum_over_x=\', I_sum_over_x)\n if(len(I_sum_over_x) == val[1]):\n \n I_sum2 = [I[n][0] for n in list(j)]\n # print(I_sum2)\n # print(sum(I_sum2))\n ans.append(sum(I_sum2))\n\n# print(ans)\nif(len(ans) == 0):\n print(\'-1\')\nelse:\n print(int(min(ans)))']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s444183583', 's562713435', 's659397525', 's732732167', 's518984456']
[27372.0, 27388.0, 27412.0, 27036.0, 27360.0]
[293.0, 297.0, 296.0, 112.0, 295.0]
[1099, 1102, 1098, 804, 1104]
p02683
u075303794
2,000
1,048,576
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.
['import sys\nimport numpy as np\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nN,M,X = map(int, readline().split())\ndata = np.array(read().split(), np.int64)\ndata = data.reshape(N,-1)\nC = data[:,0]\nA = data[:,1:]\n\ncost = np.zeros(1<<N, np.int64)\ndability = np.zeros((1<<N, M), np.int64)\n\nfor i in range(N):\n cost[1<<i:1<<(i+1)] = cost[:1<<i] + C[i]\n ability[1<<i:1<<(i+1)] = ability[:1<<i] + A[i]\n \nok = np.all(ability >= X, axis=1)\n\nx = cost[ok]\nanswer = -1 if len(x) == 0 else x.min()\nprint(answer)\n\n\n', 'import sys\nimport numpy as np\n \nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n \nN,M,X = map(int, readline().split())\ndata = np.array(read().split(), np.int64)\ndata = data.reshape(N,-1)\nC = data[:,0]\nA = data[:,1:]\n \ncost = np.zeros(1<<N, np.int64)\nability = np.zeros((1<<N, M), np.int64)\n \nfor i in range(N):\n cost[1<<i:1<<(i+1)] = cost[:1<<i] + C[i]\n ability[1<<i:1<<(i+1)] = ability[:1<<i] + A[i]\n \nok = np.all(ability >= X, axis=1)\n \nx = cost[ok]\nanswer = -1 if len(x) == 0 else x.min()\nprint(answer)']
['Runtime Error', 'Accepted']
['s707915023', 's050048472']
[27284.0, 27376.0]
[109.0, 106.0]
[564, 565]
p02683
u079022693
2,000
1,048,576
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.
['from sys import stdin\ndef main():\n \n readline=stdin.readline\n n,m,x=map(int,readline().split())\n c=[]\n a=[]\n for i in range(n):\n ca=list(map(int,readline().split()))\n c.append(ca[0])\n a.append(ca[1:])\n\n print(c)\n print(a)\n \n min_res=float("inf")\n for i in range(1<<n):\n output=[]\n res=0\n rikaido=[0]*m\n for j in range(n):\n if(i>>j)&1:\n output.append(j)\n for j in output:\n res+=c[j]\n for k in range(m):\n rikaido[k]+=a[j][k]\n for k in range(m):\n if rikaido[k]<x:\n break\n else:\n min_res=min(res,min_res)\n\n if min_res==float("inf"):\n min_res=-1\n\n print(min_res)\nif __name__=="__main__":\n main()', 'from sys import stdin\ndef main():\n \n readline=stdin.readline\n n,m,x=map(int,readline().split())\n c=[]\n a=[]\n for i in range(n):\n ca=list(map(int,readline().split()))\n c.append(ca[0])\n a.append(ca[1:])\n \n min_res=float("inf")\n for i in range(1<<n):\n output=[]\n res=0\n rikaido=[0]*m\n for j in range(n):\n if(i>>j)&1:\n output.append(j)\n for j in output:\n res+=c[j]\n for k in range(m):\n rikaido[k]+=a[j][k]\n for k in range(m):\n if rikaido[k]<x:\n break\n else:\n min_res=min(res,min_res)\n\n if min_res==float("inf"):\n min_res=-1\n\n print(min_res)\nif __name__=="__main__":\n main()']
['Wrong Answer', 'Accepted']
['s847892688', 's819442580']
[9256.0, 9260.0]
[62.0, 61.0]
[816, 789]
p02683
u082978753
2,000
1,048,576
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.
['import itertools\nimport numpy as np\n\nN, M, X = map(int, input().split())\nlis_all = [list(map(int, input().split())) for _ in range(N)]\n\nlis_C = np.array(list(map(lambda x: x[0], lis_all)))\nlis_A = np.array(list(map(lambda x: x[1:], lis_all)))\n\nrow_idx = []\nbools = [True,False]\nfor boollis in itertools.product(bools, repeat=M):\n row_idx.append(list(boollis))\n\nc_min = lis_C.sum()+100\nfor i in range(len(lis_idx)):\n if all(lis_A[row_idx[i]].sum(axis=0) >= X):\n c_min = min(lis_C[row_idx[1]].sum(), c_min)\nif c_min > lis_C.sum():\n ans = -1\nelse :\n ans = c_min\nprint(ans)', 'import itertools\nimport numpy as np\n\nN, M, X = map(int, input().split())\nlis_all = [list(map(int, input().split())) for _ in range(N)]\n\nlis_C = np.array(list(map(lambda x: x[0], lis_all)))\nlis_A = np.array(list(map(lambda x: x[1:], lis_all)))\n\nrow_idx = []\nbools = [True,False]\nfor boollis in itertools.product(bools, repeat=N):\n row_idx.append(list(boollis))\n\n\nc_min = lis_C.sum()+100\nfor i in range(len(row_idx)):\n if all(lis_A[row_idx[i]].sum(axis=0) >= X):\n c_min = min(lis_C[row_idx[i]].sum(), c_min)\nif c_min > lis_C.sum():\n ans = -1\nelse :\n ans = c_min\nprint(ans)']
['Runtime Error', 'Accepted']
['s920738723', 's908333082']
[27540.0, 27632.0]
[110.0, 161.0]
[588, 589]
p02683
u091489347
2,000
1,048,576
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.
["print('-1')", "import numpy as np\nn, m, x = map(int, input().split())\nl = []\nfor i in range(n):\n l += [list(map(int, input().split()))]\n\na = 1 <<(n )\nr = []\nfor i in range(a):\n li = np.array([0 for _ in range(m +1)])\n for j in range(n):\n if i & (1 << j):\n li += l[j]\n# print(li)\n for k in range(1,m +1):\n if li[k] < x:\n break\n if k == m:\n r +=[li[0]]\n \nif len(r) == 0:\n print('-1')\nelse:\n print(min(r))"]
['Wrong Answer', 'Accepted']
['s748133214', 's376251054']
[9116.0, 27248.0]
[24.0, 203.0]
[11, 470]
p02683
u093783313
2,000
1,048,576
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.
['import itertools\nA,B,C = map(int,input().split())\n\n\na=[]\nfor i in range(A):\n a.append(list(map(int,input().split())))\nprint(a)\na.sort() \nprint(a)\n\nresult = []\nfor n in range(1,len(a)+1):\n for conb in itertools.combinations(a, n):\n result.append(list(conb)) \nprint(result)', 'import numpy as np\nimport itertools\nn,m,x=map(int,input().split())\na=[]\nfor i in range(n):\n a.append(list(map(int,input().split())))\n# a.sort()\n\nresult = []\n\nfor n in range(1,len(a)+1):\n for conb in itertools.combinations(a, n):\n result.append(np.array(conb)) \n\ncount = 0\n\nans = []\n\nfor i in range(len(result)):\n t = sum(result[i])\n print(t)\n for k in range(1,len(t)):\n print(t[k])\n if t[k] >= x:\n count += 1\n else:\n count = 0\n break\n if count == m:\n ans.append(t[0])\n count = 0\n \n \nif len(ans) > 0:\n print(ans)\n \n print(min(ans))\n \nelse:\n print(-1)\n', 'import numpy as np\nimport itertools\nn,m,x=map(int,input().split())\na=[]\nfor i in range(n):\n a.append(list(map(int,input().split())))\n# a.sort()\n\nresult = []\n\nfor n in range(1,len(a)+1):\n for conb in itertools.combinations(a, n):\n result.append(np.array(conb)) \n\ncount = 0\n\nans = []\n\nfor i in range(len(result)):\n t = sum(result[i])\n # print(t)\n for k in range(1,len(t)):\n # print(t[k])\n if t[k] >= x:\n count += 1\n else:\n count = 0\n break\n if count == m:\n ans.append(t[0])\n count = 0\n \n \nif len(ans) > 0:\n # print(ans)\n \n print(min(ans))\n \nelse:\n print(-1)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s355900523', 's574797002', 's289454400']
[13828.0, 30444.0, 30056.0]
[61.0, 404.0, 171.0]
[321, 702, 708]
p02683
u094999522
2,000
1,048,576
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.
['n,m,x = map(int, input().split())\nc, a = [0]*n, [0]*n\nfor i in range(n):\n c[i],*a[i] = map(int, input().split())\n\nb = [[a[j][i] for j in range(n)] for i in range(m)]\ns = [sum(i) for i in b]\nif min(s) < x:\n print(-1)\n exit()\nwhile min(s) >= x:\n mind = c.index(max(c))\n for i in b:\n del i[mind]\n p = c[mind]\n del c[mind]\n s = [sum(i) for i in b]\nprint(sum(c) + p)', '\nn, m, x = map(int, input().split())\nc, a = [0] * n, [0] * n\nfor i in range(n):\n c[i], *a[i] = map(int, input().split())\nl = []\nb = [[a[j][i] for j in range(n)] for i in range(m)]\nnums = [("0"*n + bin(i)[2:])[-n:] for i in range(1, 2 ** n)]\n\nfor i in nums:\n if min(sum(k[j]*int(i[j]) for j in range(len(i))) for k in b) >= x:\n l.append(sum(c[j]*int(i[j]) for j in range(len(i))))\nprint(min(l) if l else -1)']
['Wrong Answer', 'Accepted']
['s062362324', 's626408501']
[9156.0, 9332.0]
[24.0, 162.0]
[392, 419]
p02683
u099300899
2,000
1,048,576
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.
['# -*- coding: utf-8 -*-\n\nN, M, X = map(int, input().split())\nC = [input().split() for l in range(N)]\n\nmoney = -1\ntotal = 0\nX_list = [0]*M\n\nfor i in range(N):\n total += int(C[i][0])\n for j in range(M):\n X_list[j] += int(C[i][j+1])\n\ncount = 0\nfor i in X_list:\n if (i >= X):\n count += 1\n\nif (count == M):\n money = total\n\nprint("{}".format(money))\n\nfor i in range(N):\n count = 0\n for j in range(M):\n if (X_list[j] - int(C[i][j+1]) >= X):\n count += 1\n if (count == M):\n money -= int(C[i][0])\n for j in range(M):\n X_list[j] -= int(C[i][j+1])\n\nprint("{}".format(money))', 'n, m, x = map(int, input().split())\nc, a = [], []\nfor _ in range(n):\n tmp = [int(i) for i in input().split() ]\n c.append(tmp[0])\n a.append(tmp[1:])\n\nans = 10**8\nfor s in range(2**n):\n cost = 0\n d = [0] * m\n for i in range(n):\n if (s >> i & 1):\n cost += c[i]\n for j in range(m):\n d[j] += a[i][j]\n ok = True\n for j in range(m):\n if (d[j] < x):\n ok = False\n if (ok):\n ans = min(ans, cost)\n\nif (ans == 10**8):\n print("-1")\nelse:\n print(ans)']
['Wrong Answer', 'Accepted']
['s899872352', 's139054301']
[9208.0, 9192.0]
[23.0, 83.0]
[640, 538]
p02683
u100800700
2,000
1,048,576
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.
['n,m,x = map(int,input().split())\nC = [0]*n\nA = [[0]*m for i in range(n)]\nfor i in range(n):\n b = list(map(int,input().split()))\n C[i] = b[0]\n for j in range(1,m+1):\n A[i][j-1] = b[j]\n \nMAX = 100000000000\ndef dfs(a,c,i):\n if min(a)>=x:\n return cost\n elif i == n:\n return MAX\n total_A = [u+v for (u,v) in zip(a,A[i])]\n return min(dfs(a,c,i+1), dfs(total_A,c + C[i], i+1))\n\nans = dfs([0]*m,0,0)\nif ans == MAX:\n print(-1)\nelse:\n print(ans)', 'n,m,x = map(int,input().split())\nC = list()\nA = list()\nfor i in range(n):\n temp = list(map(int,input().split()))\n C.append(temp[0])\n A.append(temp[1:])\n\nmaxnum = 10000000000\ndef dfs(a,cost,i):\n if min(a) >= x:\n return cost\n elif i == n:\n return maxnum\n \n getA = [x+y for (x,y) in zip(a,A[i])]\n \n return min(dfs(a,cost,i+1), dfs(getA,cost+C[i],i+1))\n\nans = dfs([0]*m,0,0)\n\nif ans == maxnum:\n print(-1)\nelse:\n print(ans)']
['Runtime Error', 'Accepted']
['s723012110', 's160167911']
[9168.0, 9244.0]
[31.0, 30.0]
[486, 465]
p02683
u103520789
2,000
1,048,576
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.
['import itertools\n\nN,M,X = map(int, input().split())\nC_A = []\nfor _ in range(N):\n C_A.append(list(map(int, input().split())))\n# print(C_A)\n\nmin_price = 10**5 * 12 \nrikaido = [0 for _ in range(M)]\n\nfor i in itertools.product([0,1], repeat=N):\n price_rikaido = [sum(C_A[j][k]*i[j] for j in range(N)) for k in range(M+1)]\n print(i)\n print(price_rikaido)\n flag = 1\n for l in range(M):\n if price_rikaido[l+1] <X:\n flag = 0\n break\n if flag and (min_price > price_rikaido[0]):\n min_price = price_rikaido[0]\n \nif min_price == 10**5 * 12 :\n print(-1)\nelse:\n print(min_price)\n', 'import itertools\n \nN,M,X = map(int, input().split())\nC_A = []\nfor _ in range(N):\n C_A.append(list(map(int, input().split())))\n# print(C_A)\n \nmin_price = 10**5 * 12 \nrikaido = [0 for _ in range(M)]\npossible = 0\nfor i in itertools.product([0,1], repeat=N):\n price_rikaido = [sum(C_A[j][k]*i[j] for j in range(N)) for k in range(M+1)]\n # print(i)\n \n flag = 1\n for l in range(M):\n if price_rikaido[l+1] <X:\n flag = 0\n break\n if flag and (min_price >= price_rikaido[0]):\n min_price = price_rikaido[0]\n possible = 1\n \nif possible:\n print(min_price)\nelse:\n print(-1)\n']
['Wrong Answer', 'Accepted']
['s110213193', 's831718792']
[9116.0, 9240.0]
[126.0, 112.0]
[635, 659]
p02683
u107915058
2,000
1,048,576
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.
['ans = float("inf")\nfor i in range(1<<n):\n mokuhyo = [0]*m\n cost = 0\n for j in range(n):\n if i>>j&1:\n for r in range(m):\n mokuhyo[r] += c[j][r+1]\n cost += c[j][0]\n for k in mokuhyo:\n if k < x:\n break\n else:\n ans = min(ans, cost)\nprint("-1" if ans == 10**7 else ans) ', 'ans = 10**7\nfor i in range(1<<n):\n mokuhyo = [0]*m\n cost = 0\n for j in range(n):\n if i>>j&1:\n for r in range(m):\n mokuhyo[r] += c[j][r+1]\n cost += c[j][0]\n if all(k>=x for k in mokuhyo):\n ans = min(ans, cost)\nprint("-1" if ans == 10**7 else ans) ', 'n,m,x = map(int,input().split())\nc = list(list(map(int,input().split())) for _ in range(n))\nans = 10**7\nfor i in range(1<<n):\n mokuhyo = [0]*m\n cost = 0\n for j in range(n):\n if i>>j&1:\n for r in range(m):\n mokuhyo[r] += c[j][r+1]\n cost += c[j][0]\n if all(k>=x for k in mokuhyo):\n ans = min(ans, cost)\nprint("-1" if ans == 10**7 else ans) ']
['Runtime Error', 'Runtime Error', 'Accepted']
['s163567146', 's388096904', 's952460295']
[8964.0, 9128.0, 9100.0]
[26.0, 24.0, 97.0]
[364, 316, 408]
p02683
u108072608
2,000
1,048,576
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.
["n, m, x = map(int, input().split())\nca = [list(map(int, input().split())) for _ in range(n)]\n\n\nmost_row_price = 10**10\nfor i in range(2**n):\n comb = str(bin(i)[2:]).zfill(n)\n \n \n money_per_pattern = [0] * n \n total_money = 0 \n for j in range(n):\n \n \n if comb[j] == '0':\n continue\n \n \n total_money += ca[j][0]\n \n \n for k in range(m):\n understanding[k] += ca[j][k+1] \n\n for j in range(m):\n if understanding[j] < x:\n break\n else:\n most_row_price = min(total_money, most_row_price)\n\nif most_row_price == 10**10:\n print(-1)\nelse:\n print(most_row_price)", 'import numpy as np\nN, M, X = map(int, input().split())\nC = []\nfor _ in range(N):\n C.append(list(map(int, input().split())))\nC_np = np.array(C)\n\nfor i in np.sum(C_np, axis=0)[1:]:\n if i < X:\n print(-1)\n break\n\nelse:\n for i in C_np:\n pass', "n, m, x = map(int, input().split())\nca = [list(map(int, input().split())) for _ in range(n)]\n\n\nmost_row_price = 10**10\nfor i in range(2**n):\n comb = str(bin(i)[2:]).zfill(n)\n \n \n understanding = [0] * m \n total_money = 0 \n for j in range(n):\n \n \n if comb[j] == '0':\n continue\n \n \n total_money += ca[j][0]\n \n \n for k in range(m):\n understanding[k] += ca[j][k+1] \n\n for j in range(m):\n if understanding[j] < x:\n break\n else:\n most_row_price = min(total_money, most_row_price)\n\nif most_row_price == 10**10:\n print(-1)\nelse:\n print(most_row_price)"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s746233710', 's809474880', 's838350151']
[9220.0, 27272.0, 9116.0]
[26.0, 105.0, 94.0]
[1018, 329, 993]
p02683
u110199424
2,000
1,048,576
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.
["import numpy as np\n\nN, M, X = map(int, input().split())\n\ndata = [list(map(int, input().split())) for _ in range(N)]\nINF = float('int')\n\ndata_all = []\nc_min = INF\n\nfor i in range(2**N):\n data_tmp = [0]*M\n c = 0\n for j in range(N):\n if((i>>j) & 1):\n for k in range(M):\n data_tmp[k] += data[j][k+1]\n c += data[j][0]\n if(min(data_tmp) >= X):\n c_min = min(c, c_min)\n\nif(c_min == INF):\n print(-1)\nelse:\n print(c_min)\n\n\n\n", "import numpy as np\n\nN, M, X = map(int, input().split())\n\ndata = [list(map(int, input().split())) for _ in range(N)]\nINF = float('inf')\n\ndata_all = []\nc_min = INF\n\nfor i in range(2**N):\n data_tmp = [0]*M\n c = 0\n for j in range(N):\n if((i>>j) & 1):\n for k in range(M):\n data_tmp[k] += data[j][k+1]\n c += data[j][0]\n if(min(data_tmp) >= X):\n c_min = min(c, c_min)\n\nif(c_min == INF):\n print(-1)\nelse:\n print(c_min)\n\n\n\n"]
['Runtime Error', 'Accepted']
['s859970269', 's676183450']
[27140.0, 27080.0]
[108.0, 169.0]
[483, 483]
p02683
u111473084
2,000
1,048,576
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.
['INF = 10**18\n\nn, m, x = map(int, input().split())\ncosts = []\na = []\nfor i in range(n):\n cost, *tmp = map(int, input().split())\n costs.append(cost)\n a.append(tmp)\n\nans = INF\nfor i in range(1 << n):\n cost = 0\n ms = [0] * m\n for j in range(n):\n if (i >> j) & 1 == 1:\n cost += costs[j]\n for k in range(m):\n ms[k] += a[j][k]\n can_learn = True\n for j in range(m):\n if ms[j] < x:\n can_learn = False\n break\n if can_learn:\n print(cost, ms)\n ans = min(ans, cost)\n\nprint(-1 if ans == INF else ans)\n', 'INF = 10**18\n\nn, m, x = map(int, input().split())\ncosts = []\na = []\nfor i in range(n):\n cost, *tmp = map(int, input().split())\n costs.append(cost)\n a.append(tmp)\n\nans = INF\nfor i in range(1 << n):\n cost = 0\n ms = [0] * m\n for j in range(n):\n if (i >> j) & 1 == 1:\n cost += costs[j]\n for k in range(m):\n ms[k] += a[j][k]\n can_learn = True\n for j in range(m):\n if ms[j] < x:\n can_learn = False\n break\n if can_learn:\n ans = min(ans, cost)\n\nprint(-1 if ans == INF else ans)\n']
['Wrong Answer', 'Accepted']
['s035697537', 's829512274']
[9256.0, 9232.0]
[84.0, 82.0]
[601, 577]
p02683
u111652094
2,000
1,048,576
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.
['import sys\nfrom itertools import combinations\n\nN,M,X = map(int,input().split())\nCA = [list(map(int,input().split())) for _ in range(N)]\nA=[0]*(M+1)\n\nfor i in range(N):\n for j in range(1,M+1):\n A[j]+=CA[i][j]\n\nfor i in A:\n if i <X:\n print(-1)\n sys.exit()\n\nans=sum(A)\n\nfor i in range(1,N+1):\n for e in combinations(range(N),i):\n c = 0\n A = [0]*(M+1)\n for f in e:\n c += CA[f][0]\n for j in range(M):\n A[i] += CA[f][j+1]\n if min(A) >= X:\n ans = min(ans,c)\nelse:\n print(ans)', '\nimport sys\nfrom itertools import combinations\n\nN,M,X = map(int,input().split())\nCA = [list(map(int,input().split())) for _ in range(N)]\nA=[0]*(M+1)\n\nfor i in range(N):\n for j in range(1,M+1):\n A[j]+=CA[i][j]\n\nfor i in range(1,M+1):\n if A[i] <X:\n print(-1)\n sys.exit()\n\nans=sum(A)\n\nfor i in range(1,N+1):\n for e in combinations(range(N),i):\n c = 0\n A = [0]*(M+1)\n for f in e:\n c += CA[f][0]\n for j in range(M):\n A[i] += CA[f][j+1]\n if min(A) >= X:\n ans = min(ans,c)\nelse:\n print(ans)', '\nimport sys\nfrom itertools import combinations\n\nN,M,X = map(int,input().split())\nCA = [list(map(int,input().split())) for _ in range(N)]\nA=[0]*(M+1)\n\nans=0\n\nfor i in range(N):\n ans+=CA[i][0]\n for j in range(1,M+1):\n A[j]+=CA[i][j]\n\n\nfor i in range(1,M+1):\n if A[i] <X:\n print(-1)\n sys.exit()\n\n\nfor i in range(1,N+1):\n for e in combinations(range(N),i):\n c = 0\n A = [0]*M\n for f in e:\n c += CA[f][0]\n for j in range(M):\n A[j] += CA[f][j+1]\n if min(A) >= X:\n ans = min(ans,c)\n \nelse:\n print(ans)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s099255565', 's351737563', 's777446397']
[9248.0, 9252.0, 9160.0]
[22.0, 78.0, 76.0]
[577, 592, 612]
p02683
u123872895
2,000
1,048,576
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.
['import numpy as np\nfrom numpy import array\n\n\nn, m, x = list(map(int, input().split()))\na = []\nfor i in range(n):\n a.append(list(map(int, input().split())))\n\na = array(a)\n\nc_min = 1e5 * n\nflag = False\n\nfor i in range(1, n ** 2 + 1):\n j = str(bin(i))\n\n b = np.zeros(m+1)\n\n for k in range(n):\n if j[k] == 1:\n b += a[k]\n \n if np.all(b[1:] >= m):\n c_min = min(c_min, b[0])\n flag = True\n\nif flag == False:\n c_min = -1\n\nprint(c_min)\n\n', 'import numpy as np\nfrom numpy import array\n\n\nn, m, x = list(map(int, input().split()))\na = []\nfor i in range(n):\n a.append(list(map(int, input().split())))\n\na = array(a)\n\nc_min = 0\nflag = False\n\nfor i in range(1, 2 ** n ):\n b = np.zeros(m+1)\n\n for k in range(n):\n if ((i >> k) & 1):\n b += a[k]\n \n if np.all(b[1:] >= x):\n if flag == False:\n c_min = b[0]\n flag = True\n else:\n c_min = min(c_min, b[0])\n \n\nc_min = int(c_min)\n\nif flag == False:\n c_min = -1\n\nprint(c_min)\n\n']
['Runtime Error', 'Accepted']
['s495687029', 's537601793']
[27160.0, 27252.0]
[108.0, 167.0]
[480, 557]
p02683
u125799132
2,000
1,048,576
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.
['from itertools import product\n[N, M, X] = [int(i) for i in input().split()]\nbk = [[int(i) for i in input().split()] for _ in range(N)]\n\nans = 12*10**5\nfor seq in product(range(2), repeat=N):\n S = [0]*(M+1)\n for i in range(N):\n for j in range(M+1):\n S[j] += seq[i]*bk[i][j]\n print(S, seq) \n if min(S[1:M+1]) >= X:\n ans = min(ans, S[0]) \n\nprint(ans)', 'from itertools import product\n[N, M, X] = [int(i) for i in input().split()]\nbk = [[int(i) for i in input().split()] for _ in range(N)]\n\nans = 12*10**5 + 1\nfor seq in product(range(2), repeat=N):\n S = [0]*(M+1)\n for i in range(N):\n for j in range(M+1):\n S[j] += seq[i]*bk[i][j] \n if min(S[1:M+1]) >= X:\n ans = min(ans, S[0])\n\nif ans == 12*10**5 + 1:\n print(-1)\nelse:\n print(ans)']
['Wrong Answer', 'Accepted']
['s305683538', 's375507009']
[9156.0, 9152.0]
[180.0, 165.0]
[388, 419]
p02683
u139940813
2,000
1,048,576
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.
['import numpy as np\nN,M,X= map(int,input().split())\na = []\nd = 0\ne = False\nf = []\nz = 0\nfor i in range(N):\n a.append([])\n\nfor i in range(N):\n a[i]= [int(i) for i in input().split()]\n\nfor i in range(2 ** N):\n b = np.array([0 for _ in range(M + 1)])\n d = True\n for j in range (N):\n\n if ((i >> j) & 1):\n b = np.array(a[j]) + b\n print(b)\n z = z + 1\n for k in range(M):\n if b[k + 1] < X:\n d = False\n if d:\n f.append(b[0].tolist())\n e = True\nif e:\n print(min(f))\nelse:\n print("-1")', 'import numpy as np\nN,M,X= map(int,input().split())\na = []\nd = 0\ne = False\nf = []\nz = 0\nfor i in range(N):\n a.append([])\n\nfor i in range(N):\n a[i]= [int(i) for i in input().split()]\n\nfor i in range(2 ** N):\n b = np.array([0 for _ in range(M + 1)])\n d = True\n for j in range (N):\n\n if ((i >> j) & 1):\n b = np.array(a[j]) + b\n print(b)\n z = z + 1\n for k in range(M):\n if b[k + 1] < X:\n d = False\n if d:\n f.append(b[0].tolist())\n e = True\nif e:\n print(min(f))\nelse:\n print("-1")', 'import numpy as np\nN,M,X= map(int,input().split())\na = []\nd = 0\ne = False\nf = []\nz = 0\nfor i in range(N):\n a.append([])\n\nfor i in range(N):\n a[i]= [int(i) for i in input().split()]\n\nfor i in range(2 ** N):\n b = np.array([0 for _ in range(M + 1)])\n d = True\n for j in range (N):\n\n if ((i >> j) & 1):\n b = np.array(a[j]) + b\n z = z + 1\n for k in range(M):\n if b[k + 1] < X:\n d = False\n if d:\n f.append(b[0].tolist())\n e = True\nif e:\n print(min(f))\nelse:\n print("-1")']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s510726536', 's829731909', 's108524188']
[27532.0, 27492.0, 27296.0]
[387.0, 384.0, 190.0]
[557, 557, 544]
p02683
u140191608
2,000
1,048,576
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.
['N, M, X = map(int, input().split())\nC = [0] * N\nAA = [list(map(int, input().split())) for i in range(N)]\nfor i in range(len(AA)):\n C[i] = AA[i][0]\n A[i] = AA[i][1:]\nans = sum(C) + 1\nfor p in range(2 ** N):\n Y = [0] * M\n cnt = 0\n for i, c in enumerate(C):\n if p % 2 == 1:\n cnt += c\n for j, a in enumerate(A[i]):\n Y[j] += a\n p //= 2\n ans = min(ans, cnt) if min(Y) >= X else ans\nprint(ans if ans <= sum(C) else -1)', 'N, M, X = map(int, input().split())\nC = [0] * N\nA = [0] * N\nAA = [list(map(int, input().split())) for i in range(N)]\n\nfor i in range(len(AA)):\n C[i] = AA[i][0]\n A[i] = AA[i][1:]\n\nans = sum(C) + 1\n\nfor p in range(2 ** N):\n Y = [0] * M\n cnt = 0\n for i, c in enumerate(C):\n if p % 2 == 1:\n cnt += c\n for j, a in enumerate(A[i]):\n Y[j] += a\n p //= 2\n \n \n \n ans = min(ans, cnt) if min(Y) >= X else ans\nprint(ans if ans <= sum(C) else -1)']
['Runtime Error', 'Accepted']
['s985296994', 's657207081']
[9220.0, 9128.0]
[21.0, 76.0]
[480, 871]
p02683
u141574039
2,000
1,048,576
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.
['import itertools\nN,M,X=map(int,input().split())\nA=[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\nfor i in range(N):\n S=list(map(int,input().split()))\n C[i]=S[0]\n A[i]=S[1:len(S)]\n#print(C)\n#print(A)\nfor i in range(len(C)):\n x.append(i)\n\nfor i, _ in enumerate(x, 1): \n for j in itertools.permutations(x, r=i):\n for k in x:\n for l in range(M):\n D[l]=D[l]+A[k][l]\n for v in range(M):\n if D[v]<X:\n f=1\n if f!=1:\n for y in x:\n p=p+C[y]\n if p<cost:\n cost=p\n p=0\nprint(cost if cost!=100000 else -1)', 'from collections import deque\nN,M,X=map(int,input().split())\nA=[0]*N;cost=0;C=[0]*N;bit=0;v=[0]*M;f=0;minimum=100000*12+1;e=0\nfor i in range(N):\n a = deque(list(map(int, input().split())))\n C[i]=a[0]\n a.popleft()\n A[i]=a\n\n#print(A[2][2])\n#print(C)\n\nfor i in range(2**N):\n for j in range(N):\n bit=(1<<j)\n if (i & bit)>0:\n cost+=C[N-1-j]\n for k in range(M):\n v[k]=v[k]+A[N-1-j][k]\n for l in range(M):\n if v[l]<X:\n f=1\n \n if f!=1 and cost<minimum:\n minimum=cost\n e=i\n cost=0;v=[0]*M;f=0\n \nprint(minimum if minimum!=100000*12+1 else "-1")']
['Wrong Answer', 'Accepted']
['s752978564', 's939765182']
[9124.0, 9408.0]
[2205.0, 110.0]
[650, 594]
p02683
u152402277
2,000
1,048,576
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.
['N, M, X = map(int, input().split())\nbook_list = []\n\nfor i in range(N):\n book_list.append(list(map(int, input().split())))\n\nprint("-1")\n', 'N, M, X = map(int, input().split())\nbook_list = []\ncost = [0] * (2 ** N)\n\ncost_parform = []\nfor i in range(N):\n book_list.append(list(map(int, input().split())))\nfor i in range(2 ** N):\n bag = []\n rikaido = [0] * M\n for j in range(N): \n if (i >> j & 1):\n bag.append(j)\n for k in bag:\n # print(bag)\n # print(bag[k])\n cost[i] = cost[i] + book_list[k][0]\n for m in range(M):\n rikaido[m] = rikaido[m] + book_list[k][m+1]\n\n count = 0\n for m in range(M):\n if rikaido[m] >= X:\n count += 1\n if count == M:\n cost_parform.append(cost[i])\n\nif len(cost_parform) == 0:\n x = -1\n print(x)\nelse:\n print(min(cost_parform))\n\n#print(cost_parform)']
['Wrong Answer', 'Accepted']
['s650757555', 's981171713']
[9164.0, 9220.0]
[20.0, 96.0]
[138, 784]
p02683
u163783894
2,000
1,048,576
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.
['import numpy as np\n\nN, M, X = map(int, input().split())\nC = np.zeros(N)\nA = np.zeros((N, M))\n\n\nfor n in range(N):\n s = list(map(int, input().split()))\n C[n] = s[0]\n A[n] = s[1:]\n\nC_MIN = -1\nfor i in range(2 ** N):\n C_SUM = 0\n A_SUM = np.zeros(M)\n for j in range(N):\n if ((i >> j) & 1):\n C_SUM += C[j]\n A_SUM += A[j]\n if np.all(A_SUM >= X):\n if C_SUM < C_MIN and not C_MIN == -1:\n C_MIN = C_SUM\n \nif C_MIN == -1:\n print("-1")\nelse:\n print(int(C_MIN))', 'import numpy as np\n\nN, M, X = map(int, input().split())\nC = np.zeros(N)\nA = np.zeros((N, M))\n\n\nfor n in range(N):\n s = list(map(int, input().split()))\n C[n] = s[0]\n A[n] = s[1:]\n\nC_MIN = -1\nfor i in range(2 ** N):\n C_SUM = 0\n A_SUM = np.zeros(M)\n for j in range(N):\n if ((i >> j) & 1):\n C_SUM += C[j]\n A_SUM += A[j]\n if np.all(A_SUM >= X):\n if C_SUM < C_MIN and not C_MIN == -1:\n C_MIN = C_SUM\n \nif C_MIN == -1:\n print("-1")\nelse:\n print(int(C_MIN))', 'import numpy as np\n\nN, M, X = map(int, input().split())\nC = np.zeros(N)\nA = np.zeros((N, M))\n\n\nfor n in range(N):\n s = list(map(int, input().split()))\n C[n] = s[0]\n A[n] = s[1:]\n\nC_MIN = -1\nfor i in range(2 ** N):\n C_SUM = 0\n A_SUM = np.zeros(M)\n for j in range(N):\n if ((i >> j) & 1):\n C_SUM += C[j]\n A_SUM += A[j]\n if np.all(A_SUM >= X):\n if C_SUM < C_MIN or C_MIN == -1:\n C_MIN = C_SUM\n \nif C_MIN == -1:\n print("-1")\nelse:\n print(int(C_MIN))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s294031698', 's389503822', 's065871500']
[27172.0, 27184.0, 27244.0]
[180.0, 167.0, 168.0]
[534, 534, 529]
p02683
u163829702
2,000
1,048,576
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.
["N, M, X = map(int, input().split())\n\nC = []\nA = [[] for _ in range(M)]\nfor i in range(N):\n arr = list(map(int, input().split()))\n C.append(arr[0])\n for j in range(M):\n A[j].append(arr[j+1])\n\ncount = 0\nfor i in range(M):\n if X <= sum(A[i]):\n count += 1\n\nans = [sum(A[i]) for i in range(M)]\nans_flag = [False for _ in range(M)]\ncost = sum(C)\nif count != M:\n print('-1')\nelse:\n for _ in range(M):\n idx = C.index(max(C))\n baf = C[idx]\n for i in range(M):\n ans[i] -= A[i][idx]\n if ans[i] < X:\n ans_flag[i] = True\n del A[i][idx]\n \n cost -= C[idx]\n del C[idx]\n\n if (sum(ans_flag) > 0):\n break\n\n print(cost+baf)", 'N, M, X = map(int, input().split())\ncost = []\nA = []\nfor _ in range(N):\n ca = list(map(int, input().split()))\n cost.append(ca[0])\n A.append(ca[1:])\n\nans = 10**9\nfor bit in range(2**N):\n alg = [0]*M\n c = 0\n for i in range(N):\n if bit >> i & 1 == 1:\n for j in range(M):\n alg[j] += A[i][j]\n c += cost[i]\n if min(alg) >= X:\n ans = min(ans, c)\n\nif ans == 10**9:\n print(-1)\nelse:\n print(ans)']
['Wrong Answer', 'Accepted']
['s269396389', 's775597058']
[9268.0, 9160.0]
[22.0, 81.0]
[746, 463]
p02683
u166340293
2,000
1,048,576
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.
['N,M,X=map(int,input().split())\nl=[]\nfor i in range (N):\n l.append(list(map(int,input().split())))\nans=10000000\nfor i in range(2**N):\n score=[0]*M\n coin=0\n for j in range(N):\n if i>=2**(N-1-j):\n for p in range(M):\n score[p]+=l[j][p+1]\n coin+=l[j][0]\n i-=2**(N-1-j)\n flag=0\n for q in range(M):\n if score[q]<X:\n flag=1\n if flag==0:\n if ans>coin:\n ans=coin\nif ans=10000000:\n print("-1")\nelse:\n print(ans)', 'N,M,X=map(int,input().split())\nl=[]\nfor i in range (N):\n l.append(list(map(int,input().split())))\nans=0\nfor i in range(2**N):\n score=[0]*M\n coin=0\n for j in range(N):\n if i>=2**(N-1-j):\n for p in range(M):\n score[p]+=l[j][p+1]\n coin+=l[j][0]\n i-=2**(N-1-j)\n flag=0\n for q in range(M):\n if score(q)<X:\n flag=1\n if flag==0:\n if ans<coin:\n ans=coin\nprint(coin)', 'N,M,X=map(int,input().split())\nl=[]\nfor i in range (N):\n l.append(list(map(int,input().split())))\nans=10000000\nfor i in range(2**N):\n score=[0]*M\n coin=0\n for j in range(N):\n if i>=2**(N-1-j):\n for p in range(M):\n score[p]+=l[j][p+1]\n coin+=l[j][0]\n i-=2**(N-1-j)\n flag=0\n for q in range(M):\n if score[q]<X:\n flag=1\n if flag==0:\n if ans>coin:\n ans=coin\nif ans==10000000:\n print("-1")\nelse:\n print(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s641462976', 's654927112', 's932462503']
[9000.0, 9236.0, 9212.0]
[20.0, 22.0, 103.0]
[450, 407, 451]
p02683
u167908302
2,000
1,048,576
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.
['# coding:utf-8\nn, m, x = map(int, input().split())\n\nbook = [list(map(int, input().split())) for _ in range(n)]\nall_book = [0] * m\n\nfor i in range(0, n):\n for j in range(0, m):\n all_book[j] += book[i][j]\n\nfor i in range(1, m):\n if all_book[i] < x:\n print(-1)\n exit()\n\nprice = all_book[0]\nprint(price)\n\nfor i in range(0, n):\n if all(item >= x for item in all_book):\n price = (min(price, all_book[0]))\n else:\n print(price)\n exit()\n for j in range(0, m):\n all_book[j] -= book[i][j]\n', '# coding:utf-8\n\nn, m, x = map(int, input().split())\nbook = [list(map(int, input().split())) for _ in range(n)]\nans = 12 * (10 ** 5) + 1\n\nfor bit in range(2 ** n):\n tmp_book = [0] * m\n price = 0\n for i in range(n):\n if ((bit >> i) & 1):\n price += book[i][0]\n for j in range(m):\n tmp_book[j] += book[i][j + 1]\n if all(item >= x for item in tmp_book):\n ans = min(price, ans)\n\nif ans != 12 * (10 ** 5) + 1:\n print(ans)\nelse:\n print(-1)\n']
['Wrong Answer', 'Accepted']
['s482748082', 's880252233']
[9232.0, 9148.0]
[22.0, 92.0]
[542, 515]
p02683
u168139048
2,000
1,048,576
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.
["import sys\nsys.setrecursionlimit(10000000)\nINF = 10 ** 10\nans = INF\n\n\ndef rec(A, C, X, idx, ability, sum_):\n if idx == len(A):\n for i in range(len(ability)):\n if ability[i] < X:\n break\n else:\n global ans\n ans = min(sum_, ans)\n else:\n # not buy\n rec(A, C, X, idx+1, ability, sum_)\n M = len(A[0])\n import copy \n for i in range(M):\n ability[i] += A[idx][i]\n rec(A, C, X, idx+1, copy.copy(ability), sum_+C[idx])\n\n\ndef main():\n N, M, X = map(int, input().split())\n C = []\n A = []\n for i in range(N):\n lists = [int(c) for c in input().split()]\n ci = lists[0]\n ai = lists[1:]\n C.append(ci)\n A.append(ai)\n\n ability = [0] * M\n rec(A, C, X, 0, ability, 0)\n\n if ans == INF:\n print(-1)\n else:\n print(ans)\n \n\n \n \n\n\n\nif __name__ == '__main__':\n main()\n", "import sys\nsys.setrecursionlimit(10000000)\nimport numpy as np\n\n\n\ndef main():\n N, M, X = map(int, input().split())\n C = []\n A = []\n INF = 10 ** 10\n ans = INF\n for i in range(N):\n lists = [int(c) for c in input().split()]\n ci = lists[0]\n ai = lists[1:]\n C.append(ci)\n A.append(ai)\n\n\n for i in range(1 << N):\n ability = np.zeros((M, ))\n cost = 0\n for j in range(N):\n if (i >> j) & 1:\n ability += np.array(A[j])\n cost += C[j]\n if sum(ability >= X) == M:\n ans = min(ans, cost)\n\n if ans == INF:\n print(-1)\n else:\n print(ans)\n \n\n \n \n\n\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Accepted']
['s609914876', 's765465148']
[9304.0, 27260.0]
[35.0, 260.0]
[944, 732]
p02683
u168832623
2,000
1,048,576
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.
['import numpy as np\nimport itertools\n \nN, M, X = list(map(int, input().split()))\nArr = np.zeros((N,M+1))\nList = np.zeros(M)\n \nfor i in range(N):\n Arr[i] = list(map(int, input().split()))\n \nfor j in range(M):\n List[j] = np.sum(Arr[:,j])\n\nif np.any(List<10):\n print(-1)\n\nelse:\n List = sorted(List)\n for i in range(N+1):\n for team in itertools.combinations(List,i):\n Sum = np.sum(Arr[team,:])\n if np.all(Sum>=10):\n break', 'import numpy as np\nimport itertools\n\nN, M, X = list(map(int, input().split()))\nArr = np.zeros((N,M+1))\nList = np.zeros(M)\n\nfor i in range(N):\n Arr[i] = list(map(int, input().split()))\n \nfor j in range(M):\n List[j] = np.sum(Arr[:,j])\n\nif np.any(List<10):\n print(-1)\n \nelse:\n List = sorted(List)\n for i in range(N+1):\n for team in itertools.combinations(List,i):\n Sum = np.sum(Arr[team,:])\n if np.all(Sum>=10):\n break\n \n \n', 'N,M,X = map(int,input().split())\nB = [list(map(int,input().split())) for i in range(N)]\nANS = 10**5 * 12 + 1\nfor i in range(1<<N):\n SCORE=[0]*M\n MONEY=0\n for j in range(N):\n if (1<<j) & i != 0:\n MONEY+=B[j][0]\n for k in range(M):\n SCORE[k]+=B[j][k+1]\n if min(SCORE)>=X:\n ANS=min(ANS,MONEY)\nif ANS == 10**5 * 12 + 1:\n print(-1)\nelse:\n print(ANS)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s114200990', 's577663317', 's489246298']
[27248.0, 27152.0, 9220.0]
[106.0, 110.0, 88.0]
[478, 451, 414]
p02683
u174181999
2,000
1,048,576
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.
['import itertools\n \nN, M, X = map(int, input().split())\nl = []\nfor _ in range(N):\n l.append(list(map(int, input().split())))\n\nb = [i for i in range(N)]\nn = len(b)\n\nb_pairs = []\nfor i in range(1, n+1):\n b_pairs += list(itertools.combinations(b, i))\n\ncnt = 0\nA = [0] * M\nB = []\nC = []\nfor i in range(2 ** N - 1):\n w = len(b_pairs[i])\n for j in range(M):\n for k in range(w):\n A[j] += l[b_pairs[i][k]][j + 1]\n B.append(A)\n A = [0] * M\n \nfor i in range(2 ** N - 1):\n w = len(b_pairs[i])\n for k in range(w):\n cnt += l[b_pairs[i][k]][0]\n C.append(cnt)\n cnt = 0\n\nfor i in range(len(B)):\n for j in range(M):\n if B[i][j] >= X:\n pass\n else:\n B[i] = 0\n break\n\nfor i in range(len(B)):\n if B[i] != 0:\n break\n else:\n print(-1)\n\nfor i in range(len(B)):\n if B[i] != 0:\n B[i] = C[i]\n else:\n B[i] = 1000000000000\n\nprint(min(B))', 'import itertools\n \nN, M, X = map(int, input().split())\nl = []\nfor _ in range(N):\n l.append(list(map(int, input().split())))\n\nb = [i for i in range(N)]\nn = len(b)\n\nb_pairs = []\nfor i in range(1, n+1):\n b_pairs += list(itertools.combinations(b, i))\n\ncnt = 0\nA = [0] * M\nB = []\nC = []\nfor i in range(2 ** N - 1):\n w = len(b_pairs[i])\n for j in range(M):\n for k in range(w):\n A[j] += l[b_pairs[i][k]][j + 1]\n B.append(A)\n A = [0] * M\n \nfor i in range(2 ** N - 1):\n w = len(b_pairs[i])\n for k in range(w):\n cnt += l[b_pairs[i][k]][0]\n C.append(cnt)\n cnt = 0\n\nfor i in range(len(B)):\n for j in range(M):\n if B[i][j] >= X:\n pass\n else:\n B[i] = 0\n break\nif B == [0] * len(B):\n print(-1)\n exit()\n\nfor i in range(len(B)):\n if B[i] != 0:\n B[i] = C[i]\n else:\n B[i] = 1000000000000\n\nprint(min(B))']
['Wrong Answer', 'Accepted']
['s089080246', 's760261721']
[11792.0, 11772.0]
[109.0, 100.0]
[869, 839]
p02683
u174523836
2,000
1,048,576
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.
["from copy import deepcopy\n\nN, M, X = [int(i) for i in input().split()]\n\nCAS = [[int(i) for i in input().split()] for _ in range(N)]\n\n\nok = False\nmi = [float('inf'), *[0]*(M-1)]\n\nfs = '{:0' + str(N-1) + 'b}'\n\nfor i in range(2**N):\n s = fs.format(i)\n t = [0]*M\n for i, f in enumerate(s):\n if f == '1':\n t = [a+b for a, b in zip(CAS[i], t)]\n\n if all(a >= X for a in t[1:]) and mi[0] > t[0]:\n mi = t\n ok = True\n\n\nif ok:\n print(mi[0])\nelse:\n print(-1)\n", "from copy import deepcopy\n\nN, M, X = [int(i) for i in input().split()]\n\nCAS = [[int(i) for i in input().split()] for _ in range(N)]\n\n\nok = False\nmi = [float('inf'), *[0]*(M)]\n\nfor i in range(2**N):\n t = [0]*(M+1)\n for j in range(N):\n if (i >> j) & 1:\n t = [a+b for a, b in zip(CAS[j], t)]\n\n if all(a >= X for a in t[1:]) and mi[0] > t[0]:\n mi = t\n ok = True\n\n\nif ok:\n print(mi[0])\nelse:\n print(-1)\n"]
['Wrong Answer', 'Accepted']
['s181848903', 's149324908']
[9284.0, 9248.0]
[65.0, 65.0]
[467, 417]
p02683
u182898140
2,000
1,048,576
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.
['n,m,x=map(int,input().split())\nc=[list(map(int,input().split())) for _ in range(n)]\nresult=-1\nfor i in range(2**n):\n t=[0]*m\n money=0\n for j in range(n):\n if (i>>j)&1==0:\n continue\n money+=c[j][0]\n for k in range(1,m):\n t[k]+=c[j][k]\n if all(xx>=x for xx in t):\n if result==-1:\n result=money\n else:\n result=min(result,money)\nprint(result)', 'n,m,x=map(int,input().split())\nc=[]\na=[]\nresult=-1\nfor _ in range(n):\n t=list(map(int,input().split()))\n c.append(t[0])\n a.append(t[1:])\n\nfor i in range(2**n):\n money=0\n tm=[0]*m\n for j in range(n):\n if (i>>j)&1==0:\n continue\n money+=c[j]\n for k in range(m):\n tm[k]+=a[j][k]\n if all(xx>=x for xx in tm):\n if result==-1:\n result=money\n else:\n result=min(money,result)\nprint(result)']
['Wrong Answer', 'Accepted']
['s480615412', 's238311460']
[9200.0, 9252.0]
[78.0, 101.0]
[377, 432]
p02683
u185325486
2,000
1,048,576
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.
['N,M,X = map(int, input().split())\nA = np.array([[int(i) for i in input().split()] for _ in range(N)])\ntotal = np.sum(A,axis=0)\nflag = True if all((a>=X for a in total[1:])) else False\nans = total[0]\n\nif flag:\n for i in range(1,N+1):\n for v in itertools.combinations([i for i in range(N)], i):\n B = np.array([A[j] for j in v])\n total2 = np.sum(B, axis=0)\n sabun = total-total2\n if all(a>=X for a in sabun[1:]):\n ans = min(ans, sabun[0])\nprint(ans if flag else -1)', 'import numpy as np\nimport itertools\n\ndef check():\n N,M,X = map(int, input().split())\n A = np.array([[int(i) for i in input().split()] for _ in range(N)])\n total = np.sum(A,axis=0)\n flag = True if all((a>=X for a in total[1:])) else False\n ans = total[0]\n\n if flag:\n for i in range(1,N+1):\n for v in itertools.combinations([i for i in range(N)], i):\n B = np.array([A[j] for j in v])\n total2 = np.sum(B, axis=0)\n sabun = total-total2\n if all(a>=X for a in sabun[1:]):\n ans = min(ans, sabun[0])\n print(ans if flag else -1)\n \ncheck()']
['Runtime Error', 'Accepted']
['s549910051', 's110428663']
[9236.0, 27316.0]
[27.0, 167.0]
[532, 651]
p02683
u186542450
2,000
1,048,576
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.
['import itertools\nimport sys\nimport numpy as np\n\nN, M, X = map(int, input().split())\nC = []\nfor n in range(N):\n C.append(list(map(int, input().split())))\n\nresult = []\nfor n in range(2 ** N):\n ii = [0] * N\n for i in range(N):\n if (n >> i) & 1:\n ii[i] = 1\n # print(ii)\n tmp = [0] * (M + 1)\n for j in range(len(ii)):\n if ii[j] == 1:\n tmp = (np.array(tmp) + np.array(C[j])).tolist()\n result.append(tmp)\n\n\ndef ex(array):\n for i in array:\n if i < X:\n return False\n return True\n\n\nmin_value = -1\nfor r in result:\n if ex(r):\n min_value = min(min_value, r[0])\nprint(min_value) if min_value != -1 else print(-1)\n', 'import itertools\nimport sys\nimport numpy as np\n\nN, M, X = map(int, input().split())\nC = []\nfor n in range(N):\n C.append(list(map(int, input().split())))\n\nresult = []\nfor n in range(2 ** N):\n ii = [0] * N\n for i in range(N):\n if (n >> i) & 1:\n ii[i] = 1\n # print(ii)\n tmp = [0] * (M + 1)\n for j in range(len(ii)):\n if ii[j] == 1:\n tmp = (np.array(tmp) + np.array(C[j])).tolist()\n result.append(tmp)\n\n\ndef ex(array):\n for i in array:\n if i < X:\n return False\n return True\n\n\nmin_value = sys.maxsize\nfor r in result:\n print(r)\n if ex(r):\n min_value = min(min_value, r[0])\nprint(min_value) if min_value != sys.maxsize else print(-1)\n', 'import itertools\nimport sys\nimport numpy as np\n\nN, M, X = map(int, input().split())\nC = []\nfor n in range(N):\n C.append(list(map(int, input().split())))\n\nresult = []\nfor n in range(2 ** N):\n ii = [0] * N\n for i in range(N):\n if (n >> i) & 1:\n ii[i] = 1\n # print(ii)\n tmp = [0] * (M + 1)\n for j in range(len(ii)):\n if ii[j] == 1:\n tmp = (np.array(tmp) + np.array(C[j])).tolist()\n result.append(tmp)\n\n\ndef ex(array):\n for i in array[1:]:\n if i < X:\n return False\n return True\n\n\nmin_value = sys.maxsize\nresult.sort()\nfor r in result:\n if ex(r):\n print(r[0])\n exit()\n\nprint(-1)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s194335867', 's403138764', 's424231967']
[29048.0, 29204.0, 28660.0]
[217.0, 229.0, 219.0]
[691, 722, 672]
p02683
u190167135
2,000
1,048,576
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.
['import numpy as np\nN,M,X=map(int,input().split())\nallList=[]\nfor _ in range(N):\n allList.append(np.array(list(map(int,input().split()))))\nminnum=10**7\nfor i in range(2**N):\n skill=[0]*(M+1)\n flag=True\n for row in range(N):\n if i&(2**row)>0:\n skill+=allList[row]\n for i in range(M):\n if skill[j+1]<X:\n flag=False\n if flag:\n minnum=min(minnum,skill[0])\nif minnum==10**7:\n minnum=-1\nprint(minnum)', 'import numpy as np\nN,M,X=map(int,input().split())\nallList=[]\nfor _ in range(N):\n allList.append(np.array(list(map(int,input().split()))))\nminnum=10**7\nfor i in range(2**N):\n skill=[0]*(M+1)\n flag=True\n for row in range(N):\n if i&(2**row)>0:\n skill+=allList[row]\n for j in range(M):\n if skill[j+1]<X:\n flag=False\n if flag:\n minnum=min(minnum,skill[0])\nif minnum==10**7:\n minnum=-1\nprint(minnum)']
['Runtime Error', 'Accepted']
['s865617335', 's608186676']
[27132.0, 27176.0]
[117.0, 173.0]
[457, 457]
p02683
u193264896
2,000
1,048,576
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.
["import sys\nfrom itertools import product\nimport numpy as np\nreadline = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\ndef main():\n N, M, X = map(int, readline().split())\n CA = list(list(map(int, readline().split())) for _ in range(N))\n CA = np.array(CA)\n target = [0] + [X]*M\n target = np.array(target)\n ans = INF\n for i in range(2**N):\n print(i)\n tmp = 0\n for j in range(N):\n if (i>>j)&1:\n tmp += CA[j]\n if np.all(tmp>=target):\n ans = min(ans, tmp[0])\n print(-1 if ans==INF else ans)\n\nif __name__ == '__main__':\n main()", "import sys\nfrom itertools import product\nimport numpy as np\nreadline = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\ndef main():\n N, M, X = map(int, readline().split())\n CA = list(list(map(int, readline().split())) for _ in range(N))\n CA = np.array(CA)\n target = [0] + [X]*M\n target = np.array(target)\n ans = INF\n for i in range(2**N):\n tmp = 0\n for j in range(N):\n if (i>>j)&1:\n tmp += CA[j]\n if np.all(tmp>=target):\n ans = min(ans, tmp[0])\n print(-1 if ans==INF else ans)\n\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s069042676', 's073823729']
[27368.0, 27308.0]
[155.0, 152.0]
[659, 642]
p02683
u194228880
2,000
1,048,576
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.
["nmx = input('')\nn = int(nmx.split(' ')[0])\nm = int(nmx.split(' ')[1])\nx = int(nmx.split(' ')[2])\n\nclist=[]\nalist=[]\nfor i in range(n):\n ca = input('')\n c = ca.split(' ')[0]\n clist.append(c)\n a = []\n for j in range(1,m+1):\n a.append(ca.split(' ')[j])\n alist.append(a)\n\nmin_price=99999999999\nfor i in range(2**n):\n skilllist=[0]*m\n buylist = [0]*n\n cost=0\n for j in range(n):\n if (i>>j )&1:\n buylist[j]=1\n cost+=int(clist[j])\n a = alist[j]\n for k in range(m):\n skilllist[k]+=int(a[k])\n\n ok = True\n for skill in skilllist:\n if skill < x:\n ok = False\n if ok and cost < min_price:\n min_price=cost\n print('{}:\\\\{} :{} ->{} [{}]'.format(i,cost,buylist,skilllist,min_price))\nif min_price == 99999999999:\n min_price=-1\nprint(min_price)\n\n", "nmx = input('')\nn = int(nmx.split(' ')[0])\nm = int(nmx.split(' ')[1])\nx = int(nmx.split(' ')[2])\n\nclist=[]\nalist=[]\nfor i in range(n):\n ca = input('')\n c = ca.split(' ')[0]\n clist.append(c)\n a = []\n for j in range(1,m+1):\n a.append(ca.split(' ')[j])\n alist.append(a)\n\nmin_price=99999999999\nfor i in range(2**n):\n skilllist=[0]*m\n buylist = [0]*n\n cost=0\n for j in range(n):\n if (i>>j )&1:\n buylist[j]=1\n cost+=int(clist[j])\n a = alist[j]\n for k in range(m):\n skilllist[k]+=int(a[k])\n\n ok = True\n for skill in skilllist:\n if skill < x:\n ok = False\n if ok and cost < min_price:\n min_price=cost\n\nif min_price == 99999999999:\n min_price=-1\nprint(min_price)\n\n"]
['Wrong Answer', 'Accepted']
['s057212040', 's886888845']
[9168.0, 9136.0]
[135.0, 122.0]
[871, 872]
p02683
u196629968
2,000
1,048,576
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.
['nmx=list(map(int, input().split()))\nN=nmx[0]\nM=nmx[1]\nX=nmx[2]\nmylist=[]\nfor i in range(N):\n mylist.append(list(map(int, input().split())))\nAns=10000*12+1\nfor i in range(2**N):\n A=[[0]*M]\n C=0\n for j in range(N):\n if (i>>j) & 1:\n C+=mylist[j][0]\n for k in range(M):\n A[k]=A[k]+mylist[j][k+1]\n if min(A)>=X:\n #Ans=min(Ans, C)\nif Ans==10000*12+1:\n print(-1)\nelse:\n print(Ans)\n\n', 'nmx=list(map(int, input().split()))\nN=nmx[0]\nM=nmx[1]\nX=nmx[2]\nmylist=[]\nfor i in range(N):\n mylist.append(list(map(int, input().split())))\nAns=100000*12+1\nfor i in range(2**N):\n A=[0]*M\n C=0\n for j in range(N):\n if (i>>j) & 1:\n C+=mylist[j][0]\n for k in range(M):\n A[k]+=mylist[j][k+1]\n if min(A)>=X:\n Ans=min(Ans, C)\nif Ans==100000*12+1:\n print(-1)\nelse:\n print(Ans)\n\n']
['Runtime Error', 'Accepted']
['s185856565', 's013255336']
[9080.0, 9164.0]
[25.0, 87.0]
[447, 442]
p02683
u199830845
2,000
1,048,576
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.
['import sys\nimport numpy as np\nfrom itertools import combinations\nsys.setrecursionlimit(10 ** 6) \nto_index = lambda x: int(x) - 1 \nprint_list_in_2D = lambda x: print(*x, sep="\\n") \n\n\ndef input_int():\n return int(input())\n\ndef map_int_input():\n return map(int, input())\n\nMII = map_int_input\n\ndef MII_split():\n return map(int, input().split())\n\ndef MII_to_index():\n return map(to_index, input())\n\ndef MII_split_to_index():\n return map(to_index, input().split())\n\n\ndef list_int_inputs():\n return list(map(int, input()))\n\nLII = list_int_inputs\n\ndef LII_split():\n return list(map(int, input().split()))\n\n\ndef LII_2D(rows_number):\n return [LII() for _ in range(rows_number)]\n\ndef LII_split_2D(rows_number):\n return [LII_split() for _ in range(rows_number)]\n\nN, M, X = MII_split()\n\nbooks = []\n# prices = []\nfor i in range(N):\n book = LII_split()\n # prices.append(book[0])\n books.append(book)\n\n\n# chosen_books = []\n# is_chosen = [False for _ in range(N)]\nprice = 0\nmin_price = -1\nfor i in range(N): \n\n for tmp_books in combinations(books, i + 1):\n algo_skills = np.array([0 for _ in range(M)])\n price = 0\n for skills in tmp_books:\n algo_skills += np.array(skills[1:])\n price += skills[0]\n if np.all(algo_skills >= X):\n if min_price == -1 or price < min_price:\n min_price = price\n\nprint(price)', 'import sys\nimport numpy as np\nfrom itertools import combinations\nsys.setrecursionlimit(10 ** 6) \nto_index = lambda x: int(x) - 1 \nprint_list_in_2D = lambda x: print(*x, sep="\\n") \n\n\ndef input_int():\n return int(input())\n\ndef map_int_input():\n return map(int, input())\n\nMII = map_int_input\n\ndef MII_split():\n return map(int, input().split())\n\ndef MII_to_index():\n return map(to_index, input())\n\ndef MII_split_to_index():\n return map(to_index, input().split())\n\n\ndef list_int_inputs():\n return list(map(int, input()))\n\nLII = list_int_inputs\n\ndef LII_split():\n return list(map(int, input().split()))\n\n\ndef LII_2D(rows_number):\n return [LII() for _ in range(rows_number)]\n\ndef LII_split_2D(rows_number):\n return [LII_split() for _ in range(rows_number)]\n\nN, M, X = MII_split()\n\nbooks = []\n# prices = []\nfor i in range(N):\n book = LII_split()\n # prices.append(book[0])\n books.append(book)\n\n\n# chosen_books = []\n# is_chosen = [False for _ in range(N)]\nprice = 0\nmin_price = -1\nfor i in range(N): \n\n for tmp_books in combinations(books, i + 1):\n algo_skills = np.array([0 for _ in range(M)])\n price = 0\n for skills in tmp_books:\n algo_skills += np.array(skills[1:])\n price += skills[0]\n if np.all(algo_skills >= X):\n if min_price == -1 or price < min_price:\n min_price = price\n\nprint(min_price)']
['Wrong Answer', 'Accepted']
['s143014357', 's833291253']
[27364.0, 27248.0]
[195.0, 189.0]
[1782, 1786]
p02683
u204208382
2,000
1,048,576
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.
['import numpy as np\nn,m,x = map(int,input().split())\ninfo = []\nfor i in range(n):\n info.append(list(map(int,input().split())))\ninfo = np.array(info)\n\n\nmoney = 10000000000\nflag = 0\nfor i in range(2**n):\n tem = np.zeros(m+1)\n for j in range(n):\n if ((i >> j) & 1):\n tem += info[j]\n skill = tem[1:]\n non = np.all(skill >= x)\n if non:\n flag = 1\n if tem[0] < money:\n money = tem[0]\n\nif flag == 0:\n print(-1)\nelse:\n print(money)', 'import numpy as np\nn,m,x = map(int,input().split())\ninfo = []\nfor i in range(n):\n info.append(list(map(int,input().split())))\ninfo = np.array(info)\n\nmoney = np.sum(info, axis = 0)[0]\nflag = 0\nfor i in range(2**n):\n tem = np.zeros(m+1)\n for j in range(n):\n if ((i >> j) & 1):\n tem += info[j]\n\n non = np.any(tem[1:] < x)\n if non == False:\n flag = 1\n if tem[0] < money:\n money = tem[0]\n\nif flag == 0:\n print(-1)\nelse:\n print(money)', 'import numpy as np\nn,m,x = map(int,input().split())\ninfo = []\nfor i in range(n):\n info.append(list(map(int,input().split())))\ninfo = np.array(info)\n\n\nmoney = np.sum(info, axis = 0)[0]\nflag = 0\nfor i in range(2**n):\n tem = np.zeros(m+1)\n for j in range(n):\n if ((i >> j) & 1):\n tem += info[j]\n skill = tem[1:]\n non = np.any(skill < x)\n if non == False:\n flag = 1\n if tem[0] < money:\n money = tem[0]\n\nif flag == 0:\n print(-1)\nelse:\n print(money)', 'import numpy as np\nn,m,x = map(int,input().split())\ninfo = []\nfor i in range(n):\n info.append(list(map(int,input().split())))\ninfo = np.array(info)\n\n\nmoney = np.sum(info, axis = 0)[0]\nflag = 0\nfor i in range(2**n):\n tem = np.zeros(m+1)\n for j in range(n):\n if ((i >> j) & 1):\n tem += info[j]\n skill = tem[1:]\n non = np.all(skill >= x)\n if non:\n flag = 1\n if tem[0] < money:\n money = tem[0]\n else:\n continue\n\nif flag == 0:\n print(-1)\nelse:\n print(money)', 'import numpy as np\nn,m,x = map(int,input().split())\ninfo = []\nfor i in range(n):\n info.append(list(map(int,input().split())))\ninfo = np.array(info)\n\nmoney = np.sum(info, axis = 0)[0]\nflag = 0\nfor i in range(2**n):\n tem = np.zeros(m+1)\n for j in range(n):\n if (i >> j) & 1:\n tem += info[j]\n non = np.any(tem < 10)\n if non == False:\n flag = 1\n if tem[0] < money:\n money = tem[0]\n\nif flag == 0:\n print(-1)\nelse:\n print(money)', 'import numpy as np\nn,m,x = map(int,input().split())\ninfo = []\nfor i in range(n):\n info.append(list(map(int,input().split())))\ninfo = np.array(info)\n\nmoney = np.sum(info, axis = 0)[0]\nflag = 0\nfor i in range(2**n):\n tem = np.zeros(m+1)\n for j in range(n):\n if ((i >> j) & 1):\n tem += info[j]\n\n non = np.any(tem[1:] < x)\n if non == False:\n flag = 1\n if tem[0] < money:\n money = tem[0]\n\nif flag == 0:\n print(-1)\nelse:\n print(money)', 'import numpy as np\nn,m,x = map(int,input().split())\ninfo = []\nfor i in range(n):\n info.append(list(map(int,input().split())))\ninfo = np.array(info)\n\n\nmoney = np.sum(info, axis = 0)[0]\nflag = 0\nfor i in range(2**n):\n tem = np.zeros(m+1)\n for j in range(n):\n if ((i >> j) & 1):\n tem += info[j]\n skill = tem[1:]\n non = np.all(skill >= x)\n if non:\n flag = 1\n if tem[0] < money:\n money = tem[0]\n\nif flag == 0:\n print(-1)\nelse:\n print(money)', 'import numpy as np\nn,m,x = map(int,input().split())\ninfo = []\nfor i in range(n):\n info.append(list(map(int,input().split())))\ninfo = np.array(info)\n\n\nmoney = np.sum(info, axis = 0)[0]\nflag = 0\nfor i in range(2**n):\n tem = np.zeros(m+1, dtype = int)\n for j in range(n):\n if ((i >> j) & 1):\n tem += info[j]\n skill = tem[1:]\n non = np.all(skill >= x)\n if non:\n flag = 1\n if tem[0] < money:\n money = tem[0]\n\nif flag == 0:\n print(-1)\nelse:\n print(money)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s014289512', 's119357355', 's171221886', 's376478403', 's574455933', 's899457354', 's916174668', 's656393930']
[27108.0, 27288.0, 27288.0, 27268.0, 27328.0, 27296.0, 27296.0, 27312.0]
[175.0, 174.0, 176.0, 174.0, 172.0, 174.0, 170.0, 158.0]
[488, 492, 510, 527, 486, 492, 502, 515]
p02683
u205762924
2,000
1,048,576
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.
['def intlist(x):\n y = []\n for i in range(len(x)):\n y.append(int(x[i]))\n return y\n \nN, M, X = map(int, input().split())\nprice = -1\n\nL = []\na = []\n\nsuit =[]\nfor i in range(M+1):\n a.append(0)\n \n\n# suit.append([])\n\nfor i in range(N):\n text = input().split()\n L.append(intlist(text))\n\ndef buy(x,y):\n \n if x + y <= N:\n \n for i in range(0,M+1):\n #print("x+y=",x+y)\n #print("i=",i)\n a[i] += L[x+y-1][i]\n \n print("a",a)\n if x + y == N:\n score = a[1:len(a)]\n \n if min(score) >= X:\n suit.append(a.copy())\n \n elif x + y != N:\n buy(x+1,y)\n for i in range(0,M+1):\n a[i] -= L[x+y][i]\n \n notbuy(x,y+1)\n\n\ndef notbuy(x,y):\n print("notbuy",x,y)\n if x + y <= N:\n \n if x + y == N:\n score = a[1:len(a)]\n if min(score) >= X:\n suit.append(a.copy())\n \n \n elif x + y != N:\n buy(x+1,y)\n for i in range(0,M+1):\n a[i] -= L[x+y][i]\n notbuy(x,y+1) \n\ndef textbook(x,y):\n buy(x+1,y)\n for i in range(0,M+1):\n a[i] -= L[x+y][i]\n notbuy(x,y+1)\n\ntextbook(0,0)\n\nb = []\n\nif suit != []:\n for i in range(len(suit)):\n for j in range(len(suit)-1):\n if suit[j] > suit[j+1]:\n b = suit[j]\n suit[j] = suit[j+1]\n suit[j+1] = b\n price = suit[0][0]\n\n\nprint(price)', 'def intlist(x):\n y = []\n for i in range(len(x)):\n y.append(int(x[i]))\n return y\n \nN, M, X = map(int, input().split())\nprice = -1\n \nL = []\na = []\nc = []\nsuit =[]\nfor i in range(M+1):\n a.append(0)\n \nfor i in range(N):\n text = input().split()\n L.append(intlist(text))\n \ndef buy(x,y):\n \n if x + y <= N:\n \n for i in range(0,M+1):\n \n a[i] += L[x+y-1][i]\n \n \n if x + y == N:\n score = a[1:len(a)]\n \n if min(score) >= X:\n suit.append(a.copy())\n \n elif x + y != N:\n buy(x+1,y)\n for i in range(0,M+1):\n a[i] -= L[x+y][i]\n \n notbuy(x,y+1)\n \n \ndef notbuy(x,y):\n \n if x + y <= N:\n print(a)\n if x + y == N:\n score = a[1:len(a)]\n if min(score) >= X:\n suit.append(a.copy())\n \n \n elif x + y != N:\n buy(x+1,y)\n for i in range(0,M+1):\n a[i] -= L[x+y][i]\n notbuy(x,y+1) \n \ndef textbook(x,y):\n buy(x+1,y)\n for i in range(0,M+1):\n a[i] -= L[x+y][i]\n notbuy(x,y+1)\n \ntextbook(0,0)\n \nb = []\n \nif suit != []:\n for i in range(len(suit)):\n for j in range(len(suit)-1):\n if suit[j] > suit[j+1]:\n b = suit[j]\n suit[j] = suit[j+1]\n suit[j+1] = b\n price = suit[0][0]\n \n\nprint(price)', 'def intlist(x):\n y = []\n for i in range(len(x)):\n y.append(int(x[i]))\n return y\n \nN, M, X = map(int, input().split())\nprice = -1\n\nL = []\na = []\nc = []\nsuit =[]\nfor i in range(M+1):\n a.append(0)\n \nfor i in range(N):\n text = input().split()\n L.append(intlist(text))\n\ndef buy(x,y):\n \n if x + y <= N:\n \n for i in range(0,M+1):\n \n a[i] += L[x+y-1][i]\n \n \n if x + y == N:\n score = a[1:len(a)]\n \n if min(score) >= X:\n suit.append(a.copy())\n \n elif x + y != N:\n buy(x+1,y)\n for i in range(0,M+1):\n a[i] -= L[x+y][i]\n \n notbuy(x,y+1)\n\n\ndef notbuy(x,y):\n \n if x + y <= N:\n print(a)\n if x + y == N:\n score = a[1:len(a)]\n if min(score) >= X:\n suit.append(a.copy())\n \n \n elif x + y != N:\n buy(x+1,y)\n for i in range(0,M+1):\n a[i] -= L[x+y][i]\n notbuy(x,y+1) \n\ndef textbook(x,y):\n buy(x+1,y)\n for i in range(0,M+1):\n a[i] -= L[x+y][i]\n notbuy(x,y+1)\n\ntextbook(0,0)\n\nb = []\n\nif suit != []:\n for i in range(len(suit)):\n for j in range(len(suit)-1):\n if suit[j] > suit[j+1]:\n b = suit[j]\n suit[j] = suit[j+1]\n suit[j+1] = b\n price = suit[0][0]\n\nprint(suit)\nprint(price)', 'def intlist(x):\n y = []\n for i in range(len(x)):\n y.append(int(x[i]))\n return y\n\nN, M, X = map(int, input().split())\n\nL = []\na = []\n\nfor i in range(N):\n text = input().split()\n L.append(intlist(text))\n \nfor i in range(N):\n for j in range(N-1):\n if L[j] > L[j+1]:\n a = L[j]\n L[j] = L[j+1]\n L[j+1] = a\n\nscore = []\ncount = 0\nmoney = -1\nmoney_count = 0\n\n\nfor i in range(M): \n score.append(0)\n \nfor i in range(N):\n money_count = money_count + L[i][0]\n for j in range(M):\n score[j] = score[j] + L[i][j+1]\n if min(score) >= X:\n money = money_count\n break\n\n\nscore2 = score\n\nif money != -1:\n\n for i in range(N):\n for j in range(M):\n score2[j] -= L[len(L)-1-i][j+1]\n print(score2)\n if min(score2) >= X:\n money = money - L[len(L)-1-i][0]\n else:\n for k in range(M):\n score2[k] += L[len(L)-1-i][k+1]\n \n \n \nprint(money)', 'def intlist(x):\n y = []\n for i in range(len(x)):\n y.append(int(x[i]))\n return y\n \nN, M, X = map(int, input().split())\nprice = -1\n \nL = []\na = []\nc = []\nsuit =[]\n\nfor i in range(M+1):\n a.append(0)\n \nfor i in range(N):\n text = input().split()\n L.append(intlist(text))\n \nfor i in range(2**N):\n c = a.copy()\n \n for j in range(N):\n if (i >> j) & 1:\n for k in range(M+1):\n c[k] = c[k] + L[j][k]\n suit.append(c.copy())\n \nsuit2 = []\n\nfor i in range(len(suit)):\n if min(suit[i][1:len(suit)]) >= X:\n suit2.append(suit[i])\n \n\n\nif suit2 != []:\n if len(suit2) >= 2:\n \n cheaper = suit2[0][0]\n for i in range(len(suit2)):\n if cheaper > suit2[i][0]:\n cheaper = suit2[i][0]\n price = cheaper\n elif len(suit2) == 1:\n price = suit2[0][0]\n \nprint(price)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s086662929', 's590559543', 's746991527', 's841064457', 's135320324']
[11304.0, 11268.0, 11200.0, 9312.0, 11296.0]
[2206.0, 2206.0, 2206.0, 23.0, 95.0]
[1606, 1502, 1504, 1033, 910]
p02683
u213497190
2,000
1,048,576
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.
["import itertools\nmin_price = 10**9\nfor k in range(n):\n for comb in itertools.combinations(range(m), k+1):\n sums = [0] * m\n price = 0\n for c in comb:\n price += C[c]\n for i in range(m):\n sums[i] += A[c][i]\n\n# print(comb)\n# print(sums)\n if sum([y >= x for y in sums]) == len(A):\n min_price = min(min_price, price)\n\nif min_price == 10**9:\n print('-1')\nelse:\n print(min_price)", "import itertools\n\nn,m,x = map(int,input().split())\nC, A = [], []\nfor i in range(n):\n ca = list(map(int, input().split()))\n C.append(ca[0])\n A.append(ca[1:])\n\nmin_price = 10**9\nfor k in range(n):\n for comb in itertools.combinations(range(n), k+1):\n sums = [0] * m\n price = 0\n for c in comb:\n price += C[c]\n for i in range(m):\n sums[i] += A[c][i]\n\n# print(comb)\n# print(sums)\n# print(min_price)\n if sum([y >= x for y in sums]) == m:\n min_price = min(min_price, price)\n\nif min_price == 10**9:\n print('-1')\nelse:\n print(min_price)"]
['Runtime Error', 'Accepted']
['s085950154', 's383855729']
[9144.0, 9260.0]
[26.0, 77.0]
[472, 644]
p02683
u220499476
2,000
1,048,576
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.
['import sys\n\nn, m, x =map(int,input().split())\ng = []\nfor _ in range (n):\n array = list(map(int,input().split()))\n g.append(array)\nprint(g)\n', 'n, m, x =map(int,input().split())\ns = [list(map(int, input().split())) for _ in range(n)]\nans = 10000000\nfor i in range(2 ** n):\n bag = [0]*(m+1)\n for j in range(n):\n if ((i>>j)&1):\n for _ in range(m+1):\n bag[_] += s[j][_]\n ##print(bag)\n if (min(bag[1:]) >= x and ans > bag[0]):\n ans = bag[0]\n \nif ans == 10000000:\n print("-1")\nelse:\n print(ans)\n \n ']
['Wrong Answer', 'Accepted']
['s264122784', 's773916052']
[9172.0, 9220.0]
[20.0, 88.0]
[212, 386]
p02683
u220875888
2,000
1,048,576
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.
['#! /usr/bin/env python3\n# -*- coding:utf-8 -*-\n\ndef min_needed_value(values, skills, X):\n cand = []\n for i in range(2**len(values)):\n get_skill = [0] * len(skills[0])\n get_value = 0\n for j in range(len(values)):\n if (i >> j) & 1:\n get_skill = [x + y for (x, y) in zip(get_skill, skills[j])]\n get_value += values[j]\n if all([s > X for s in get_skill]): cand.append(get_value)\n sorted(cand)\n if len(cand) == 0: return -1\n else: return cand[0]\n\n\ndef main():\n N, M, X = map(int, input().split())\n values = []\n skills = []\n for _ in range(N):\n Book = list(map(int, input().split()))\n values.append(Book[0])\n skills.append(Book[1:])\n print(min_needed_value(values, skills, X))\n\nif __name__ == "__main__":\n main()\n', '#! /usr/bin/env python3\n# -*- coding:utf-8 -*-\n\ndef min_needed_value(values, skills, X):\n import sys\n ans = sys.maxsize\n for i in range(2**len(values)):\n get_skill = [0] * len(skills[0])\n get_value = 0\n for j in range(len(values)):\n if (i >> j) & 1:\n get_skill = [x + y for (x, y) in zip(get_skill, skills[j])]\n get_value += values[j]\n \n if all([s >= X for s in get_skill]): ans = min(ans, get_value)\n if ans == sys.maxsize: return -1\n else: return ans\n\ndef main():\n N, M, X = map(int, input().split())\n values = []\n skills = []\n for _ in range(N):\n Book = list(map(int, input().split()))\n values.append(Book[0])\n skills.append(Book[1:])\n print(min_needed_value(values, skills, X))\n\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Accepted']
['s269646817', 's171776824']
[9356.0, 9228.0]
[54.0, 52.0]
[830, 880]
p02683
u227085629
2,000
1,048,576
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.
['n,m,x = map(int,input().split())\nc_list = [list(map(int,input().split())) \n for nesya in range(n)]\narugo = [0]*m\nhoge = 0\nwhile c in c_list:\n arugo[0] += c[1]\n arugo[1] += c[2]\n arugo[2] += c[3]\n hoge += c[0]\nif arugo[0] < 10 or arugo[1] < 10 or arugo[2] < 10:\n print(-1)\nelse:\n print(hoge)', 'n,m,x = map(int,input().split())\nc_list = [list(map(int,input().split())) \n for nesya in range(n)]\narugo = [0]*m\nhoge = 0\nfor c in c_list:\n arugo[0] += c[1]\n arugo[1] += c[2]\n arugo[2] += c[3]\n hoge += c[0]\nif arugo[0] < 10 or arugo[1] < 10 or arugo[2] < 10:\n print(-1)\nelse:\n print(hoge)', 'def bit_set(num:int,n:int):\n if num & (1<<n):\n return True\n return False\n\nn,m,x = map(int,input().split())\nca_list = [list(map(int,input().split())) \n for nesya in range(n)]\nc = -1\nfor i in range(2**n):\n skill = [0]*m\n cost = 0\n for k in range(n):\n if bit_set(i,k) == True:\n ca = ca_list[k]\n cost += ca[0]\n a = ca[1:]\n skill = [j+l for (j,l) in zip(skill, a)]\n if all((hoge >= x) for hoge in skill):\n if c == -1:\n c = cost\n else:\n c = min(c,cost)\nprint(c)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s090383654', 's272793388', 's166067317']
[9208.0, 9208.0, 9212.0]
[24.0, 23.0, 65.0]
[305, 303, 514]
p02683
u229518917
2,000
1,048,576
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.
['from itertools import*\nN,M,X=map(int,input().split())\nC=[list(map(int,input().split())) for i in range(N)]\nans=100**10000\nfor i in range(N+1):\n a=list(combinations(C,i))\n for s in a:\n print(s)\n A=[0 for d in range(M)]\n flag=True\n for k in range(M):\n for u in range(len(s)):\n A[k]+=s[u][k]\n B=A[1:]\n for z in B:\n if z>=X:\n continue\n else:\n flag=False\n break\n if flag==True:\n ans=min(ans,A[0])\nprint(-1 if ans==100**10000 else ans)', 'N,M,X=map(int,input().split())\nA=[list(map(int,input().split())) for _ in range (N)]\nans=10**20\n\nfor bit in range(2**N):\n C=[0]*M\n cost=0\n for i in range(N):\n if (bit>>i)&1==1:\n cost+=A[i][0]\n for j in range(1,M+1):\n C[j-1]+=A[i][j]\n if min(C)>=X:\n ans=min(ans,cost)\nprint(ans if ans!=10**20 else -1)']
['Wrong Answer', 'Accepted']
['s846457139', 's877835053']
[9456.0, 9172.0]
[126.0, 99.0]
[588, 363]
p02683
u231095456
2,000
1,048,576
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.
['C = []\nA = []\nfor _ in range(N):\n l = list(map(int,input().split()))\n C.append(l[0])\n A.append(np.array(l[1:]))\nans = 10**100\nfor i in range(2**N):\n rikaido = np.zeros(M)\n c = 0\n for j in range(N):\n if (i >> j) & 1:\n c += C[j]\n rikaido += A[j]\n if all([x >= X for x in rikaido]):\n ans = min(ans, c)\nprint(ans if ans != 10**100 else -1)', 'import numpy as np\nN,M,X = map(int,input().split())\nC = []\nA = []\nfor _ in range(N):\n l = list(map(int,input().split()))\n C.append(l[0])\n A.append(np.array(l[1:]))\nans = 10**100\nfor i in range(2**N):\n rikaido = np.zeros(M)\n c = 0\n for j in range(N):\n if (i >> j) & 1:\n c += C[j]\n rikaido += A[j]\n if all([x >= X for x in rikaido]):\n ans = min(ans, c)\nprint(ans if ans != 10**100 else -1)']
['Runtime Error', 'Accepted']
['s507040426', 's352138382']
[9144.0, 27096.0]
[29.0, 172.0]
[392, 444]